Hi mikeok,
one sample for your regexptester to demonstrate the lookahead feature
(It excludes "win 3.11" from the resulting match list of operating systems)
(?!pattern) Negative lookahead matches the search string at any
point where a string not matching pattern begins. This
is a non-capturing match, that is, the match is not
captured for possible later use. For example 'Windows
(?!95|98|NT|2000)' matches "Windows" in "Windows 3.1"
but does not match "Windows" in "Windows 2000".
Lookaheads do not consume characters, that is, after a
match occurs, the search for the next match begins
immediately following the last match, not after the
characters that comprised the lookahead.
(VBScript Docs)
^\w+ (?!3.11)\S+
-------
win 3.11
win 98
win 95
win 2K
win XP
-------
False
-------
True
-------
True
and two suggestions for further enhancements:
(1) couldn't you collect all the regexp files (in the .hta directory;
possibly identified by a suitable extension like ".re") in a
combobox and load the selected file on "onchange"?
(2) how about adding a comment field to the regexp's data?
To show what I mean:
(a) The bare bones .hta (I prefer for more complicated apps to separate
code from display/layout) - save as "rt00.hta" in a directory with some
.re2 files
<html>
<head>
<hta:application id = "refilecbx"
/>
<title>refilecbx</title>
<meta http-equiv = "Content-Type" content = "text/html; charset = ISO-8859-1" />
<meta http-equiv = "content-script-type" content = "text/vbscript" />
<script language = "VBScript" src = "rt00.vbs" type = "text/vbscript"></script>
<!-- hey, what's wrong with
<script language = "VBScript" src = "rt00.vbs" type = "text/vbscript"/>
-->
</head>
<body onload = "onloadBody()">
<input type = "BUTTON" value = "reload" onclick = "reloadHTA()">
<hr />
<select id = "cbxReFiles" size = "1" onchange = "onchangeCbxReFiles"></select>
<hr />
<input type = "TEXT" id = "sleRE">
<br />
<textarea id = "mleData"></textarea>
<br />
<input type = "checkbox" id = "cbNoCase" >Ignore Case
<br />
<input type = "checkbox" id = "cbGlobal" >Global Search
<br />
<input type = "checkbox" id = "cbMultiline">Multiline
<br />
<textarea id = "mleComment"></textarea>
</body>
</html>
(b) The bare bones VBScript code - save as "rt00.vbs" in this directory
Option Explicit
''= global FS
' ============================================================================
Dim goFS : Set goFS = CreateObject( "Scripting.FileSystemObject" )
''= fills cbxReFiles with file names from 'current' dir
' ============================================================================
Sub onloadBody()
Dim cbxReFiles : Set cbxReFiles = document.getElementById( "cbxReFiles" )
Dim oFile, oOPT
For Each oFile In goFS.GetFolder( "." ).Files
If "re2" = LCase( goFS.getExtensionName( oFile.Name ) ) Then
Set oOPT = cbxReFiles.document.createElement( "OPTION" )
oOPT.Text = oFile.Name
oOPT.Value = oFile.Path
cbxReFiles.Options.Add oOPT
End If
Next
cbxReFiles.selectedIndex = -1
End Sub
''= loads selected file, fills controls/elements
' ============================================================================
Sub onchangeCbxReFiles_how_I_got_there()
Dim cbxReFiles : Set cbxReFiles = document.getElementById( "cbxReFiles" )
Dim sFSpec : sFSpec = cbxReFiles.Options( cbxReFiles.selectedIndex ).value
MsgBox "must load " + sFSpec
Dim sText : sText = goFS.OpenTextFile( sFSpec ).ReadAll
Dim aTest : aTest = Array( _
"regexp" _
, "data" _
, True _
, True _
, True _
, "comment" _
)
setControls( aTest )
MsgBox "real set"
Dim sDelim : sDelim = vbCrLf + "-------" + vbCrLf
aTest = Split( sText, sDelim )
setControls( aTest )
End Sub
Sub onchangeCbxReFiles()
Dim cbxReFiles : Set cbxReFiles = document.getElementById( "cbxReFiles" )
Dim sFSpec : sFSpec = cbxReFiles.Options( cbxReFiles.selectedIndex ).value
Dim sText : sText = goFS.OpenTextFile( sFSpec ).ReadAll
Dim sDelim : sDelim = vbCrLf + "-------" + vbCrLf
Dim aTest : aTest = Split( sText, sDelim )
If 5 > UBound( aTest ) Then
ReDim Preserve aTest( 5 )
aTest( 5 ) = "no comment"
End If
setControls( aTest )
cbxReFiles.selectedIndex = -1
End Sub
''= puts data (aValues) into controls (elements)
' ============================================================================
Sub setControls( aValues )
document.getElementById( "sleRE" ).Value = aValues( 0 )
document.getElementById( "mleData" ).Value = aValues( 1 )
document.getElementById( "cbNoCase" ).Checked = aValues( 2 )
document.getElementById( "cbGlobal" ).Checked = aValues( 3 )
document.getElementById( "cbMultiline" ).Checked = aValues( 4 )
document.getElementById( "mleComment" ).Value = aValues( 5 )
End Sub
''= refreshes the HTA page, which includes re-running any Windows_Onload code
' yes, I deleted the ()!
' ============================================================================
Sub reloadHTA()
location.reload True
End Sub
But as I said - these are suggestions, so please don't feel pestered.
Thanks for your good work!
ehvbs