Replaces all matches of a regular expression with a new string.
In the case of overlapping matches, the leftmost instance is replaced and if
multiple matches start at the same index, then the longest one is replaced.
If the expression is empty, it matches at the beginning of the string and
after each code point, yielding up to k+1 replacements for a string with
k code points.
Note that regular expression backreferences are not supported and you can't refer to text previously matched by a capturing group.
Arguments
| Arguments | |
|---|---|
| source | 
 The subject of the function. A modified copy is returned. | 
| regexp | 
 The regular expression used for matching substrings. Uses RE2 syntax. | 
| repl | 
 The string that will replace all matches of   Backreferences are not supported. For example, you can't use the expression  | 
Returns
A copy of source where all matches of regexp are replaced by repl.
Raised exceptions
| Exceptions | |
|---|---|
| TypeError | If either source,regexp, orreplis not a string. | 
| ValueError | If either regexporreplis not UTF-8 encoded or ifregexpis an invalid regular expression. | 
Examples
# Replace matches of regular expression; returns "three three" - returnStep: return: ${text.replace_all_regex("one two", "one|two", "three")}