You can now use backreferences in replace strings. Backreferences in the replace string refer to parenthesized matched sub-expressions in the regular expression search. For example, to replace all repeated words in a text string with a single word, you can use the following syntax:
REReplace("There is is a cat in in the kitchen",
"([A-Za-z]+)[ ]+\1","\1")
This results in the sentence:
"There is a cat in in the kitchen"
You can use the optional fourth parameter in REReplace, ReturnSubExpression, to replace all repeated words, as in the following code,
REReplace("There is is a cat in in the kitchen",
"([A-Za-z]+)[ ]+\1","\1","ALL")
This results in the following string:
"There is a cat in the kitchen"
|