Usage of RegExp object:
RegExpTest(patrn,strng)
DimregEx,Match,Matches' creates variables.
SetregEx=NewRegExp' creates a regular expression.
regEx.Pattern=patrn'Set mode.
regEx.IgnoreCase=True' Set whether to be case sensitive.
regEx.Global=True' sets global availability.
SetMatches=regEx.Execute(strng)' performs the search.
ForEachMatchinMatches' traversal of matching collections.
RetStr=RetStr&"Matchfoundatposition"
RetStr=RetStr&Match.FirstIndex&".Matchis'"
RetStr=RetStr&Match.&"'."&vbCRLF
Next
RegExpTest=RetStr
End
MsgBox(RegExpTest("is.","IS1is2IS3is4"))
Properties of RegExp Object
◎Global attributes
The Global property sets or returns a Boolean value that indicates whether the pattern matches all or only the first one during the entire search string.
grammar
object.Global[=True|False]
The object parameter is always a RegExp object. If the search is applied to the entire string, the Global property has a value of True, otherwise its value is False. The default setting is True.
Usage of Global attributes (change the value assigned to the Global attribute and observe its effect):
RegExpTest(patrn,strng)
DimregEx' creates the variable.
SetregEx=NewRegExp' creates a canonical expression.
regEx.Pattern=patrn'Set mode.
regEx.IgnoreCase=True' Set whether letters are case sensitive.
regEx.Global=True' sets the full-process nature.
RegExpTest=regEx.Execute(strng)' performs the search.
End
MsgBox(RegExpTest("is.","IS1is2IS3is4"))
◎IgnoreCase attribute
The IgnoreCase property sets or returns a Boolean value indicating whether the mode search is case sensitive.
grammar
object.IgnoreCase[=True|False]
The object parameter is always a RegExp object. If the search is case sensitive, the IgnoreCase property is False; otherwise it is True. The default value is True.
Usage of the IgnoreCase attribute (change the value assigned to the IgnoreCase attribute to observe its effect):
RegExpTest(patrn,strng)
DimregEx' creates the variable.