Test method
Performs a regular expression search on the specified string and returns a Boolean indicating whether the matching pattern is found.
object.Test(string)
Parameters
Object
Required option. Always the name of a RegExp object.
String
Required option. The text string to perform a regular expression search for.
Description
The actual mode of the regular expression search is set by regexp the Pattern property of the object. The Regexp.global property has no effect on the test method.
The test method returns true if a matching pattern is found, otherwise it returns false.
The following code illustrates the use of the test method.
Function regexptest (patrn, strng) Dim regEx, retval ' to establish a variable. The set regEx = New regexp ' establishes a regular expression. Regex.pattern = patrn ' setting mode. The regex.ignorecase = false ' setting is case-sensitive. retVal = regex.test (Strng) ' to perform a search test. If retVal Then regexptest = finds one or more matches. Else regexptest = did not find a match. End If End Function MsgBox (Regexptest ("is.", "IS1 is2 IS3 is4"))