.
|
Microsoft® Visual Basic® Scripting Edition Execute Method |
Language Reference Version 5 |
Executes a regular expression search against a specified string.
object.Execute(string)The Execute method syntax has these parts:
Part Description object Required. Always the name of a RegExp object. string Required. The text string upon which the regular expression is executed.
The actual pattern for the regular expression search is set using the Pattern property of the RegExp object.The Execute method returns a Matches collection containing a Match object for each match found in string. Execute returns an empty Matches collection if no match is found.
The following code illustrates the use of the Execute method:
Function RegExpTest(patrn, strng) Dim regEx ' Create variable. Set regEx = New RegExp ' Create regular expression. regEx.Pattern = patrn ' Set pattern. regEx.IgnoreCase = False ' Set case sensitivity. regEx.Global = True ' Set for search to apply to entire string. RegExpTest = regEx.Execute(strng) ' Execute the search. End Function MsgBox(RegExpTest("is.", "IS1 is2 IS3 is4"))