Implemented in version 5.0
method is used with a
object variable to look for a search string pattern (also known as a regular expression) inside a target string.
There is one mandatory argument, the target string to be searched. The search string pattern (regular expression) is declared using the
Each time a match is made (i.e., the search pattern is found inside the target string), a
object is created and added to a
collection. Note that a match does not have to occur. Therefore the
method can return a
collection that is empty, or that contains one or more, objects.
'this sub finds the matches
Sub RegExpTest(strMatchPattern, strPhrase)
Dim objRegEx, Match, Matches, StrReturnStr
'create instance of RegExp object
Set objRegEx = New RegExp
'set the pattern
objRegEx.Pattern = strMatchPattern
'create the collection of matches
Set Matches = objRegEx.Execute(strPhrase)
'print out all matches
For Each Match in Matches
strReturnStr = "Match found at position "
strReturnStr = strReturnStr & Match.FirstIndex & ". Match Value is `"
strReturnStr = strReturnStr & Match.value & "'."
Response.Write(strReturnStr & "<BR>")
'call the subroutine
RegExpTest "is.", "Is1 is2 Is3 is4"
Match found at position 4. Match Value is `is2'.
Copyright 1999-2004 by Infinite Software Solutions, Inc. All rights reserved.