The regex_replace_all
method searches a string for matches to a regular expression, and replaces the matches according to the value specified by the replacement
argument.
regex_replace_all( input, regex, replacement )
Argument | Description |
---|---|
input
|
(string) The string in which you want to replace values. |
regex
|
(string) The regular expression to use to find values to be replaced. |
replacement
|
(string) A string that specifies how to replace the matches of the regular expression. |
(String). The modified string.
regex_replace_all("ABC ABC ABC", "AB", "A") -- returns "AC AC AC" regex_replace_all("One Two Three", "\\w{3}", "_") -- returns "_ _ _ee" regex_replace_all("One Two Three", "(\\w+) (\\w+)", "\\2 \\1") -- returns "Two One Three"
|