MoneyWorks Manual
Regex_Replace (string, regex, replacementex)
Result Type: Text
Definition: Returns string with every occurrence of regex replaced with replacementex. Regex is a regular expression. Replacementex is an expression which can contain metacharacters referring to the sequences matched in the regular expression (e.g. $1 refers to the first parenthesized group, $2 to the second. Also $& (whole match), $` (prefix), $' (suffix) This function calls through to the standard C++ std::regex_replace function using the default regex mode (be aware there may be some non-standard behaviours that differ between Mac and Windows: do not rely on non-standard behaviours ($0 being an example of such)).
Examples: Regex_Replace("foo far car bar baz", "(b|c)a(.)", "$1A$2")
returns “foo far cAr bAr bAz”.
Note: $0 works as $& on Mac but not on Windows. Don't use it.
Availability: v8.1.7 and later.
If you just want a simple (non-regex) text replacement, see Replace.
See Also:
Dice: Get a subcomponent of a delimited tabular string
Head: Get some elements from the start of a delimited string
Left: Get characters from the start of a string
Mid: Get characters from the middle of a string
Regex_GetMatches: Find tokens using a regular expression
Regex_Match: Test whether a string matches a regular expression
Regex_Search: Find the first match of a regular expression in a string
Regex_SearchStr: Find the first match of a regular expression in a string and return the matching string
RemoveLeading: Remove characters from the start of a string
RemoveTrailing: Remove characters from the end of a string
Replace: Replace matching text in a string with new text
Right: Get characters from the end of a string
Slice: Get a component of a delimited string
Tail: Get some elements from the end of a delimited string
Trim: Remove whitespace from beginning and end of a string