Version: 5.0
This method is used to replace text found in a regular expression search. Do not confuse this method with the Replace function.
It can only be used with a RegExp object variable.
The search string pattern is declared using the Pattern property. You can use the Global property to limit the search to the first occurrence of a match, or all occurrences.
<%
Dim RegX
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)
Response.Write(ReplacedText)
%>
Output:
"Ocelots make bad pets."