Method RegEx():replace() Foundation
Replaces matches with replacement text.
:replace( <cSubject>, [<cReplacement>], [<lGlobal>] ) --> cString
The modified string with the replacements.
Performs search and replace operations on the subject string. Can replace either the first match only or all matches depending on the <lGlobal> parameter. The replacement is literal text. Use the method :replaceCallback() when dynamic replacements are needed.
Replace
oRegEx := RegEx():create("\d+")
// Replace first occurrence
? oRegEx:replace("10 cats and 20 dogs", "X") // "X cats and 20 dogs"
// Replace all occurrences
? oRegEx:replace("10 cats and 20 dogs", "X", .T.) // "X cats and X dogs"
oRegEx:destroy()
If you see anything in the documentation that is not correct, does not match your experience with the particular feature or requires further clarification, please use this form to report a documentation issue.