Implemented in version 5.0
method is used to replace text in a regular expression search. It can only be used with a
Do not confuse this method with the
The search string pattern is declared using the
property. You can use the
property to limit the search to the first occurrence of a match, or all occurrences.
There are two mandatory arguments. If the search string pattern is found in one or more occurrences inside the string designated by the
argument, then, as set by the
property, the first or all occurrences of the search string pattern will be replaced with the
Set RegX = NEW RegExp
Dim MyString, SearchPattern, ReplacedText
MyString = "Ocelots make good pets."
SearchPattern = "good"
ReplaceString = "bad"
RegX.Pattern = SearchPattern
RegX.Global = True
ReplacedText = RegX.Replace(MyString, ReplaceString)
"Ocelots make bad pets."