REGEX_REPLACE
Replaces every occurrence of a regex match in text with the replacement text. The replacement can refer to capture groups by number, like \1, or by name, like \k<name>.
Categories: Text
Syntax
REGEX_REPLACE(text, regex, replacement)
Examples
Example 1
Input
1
{
2
"my_action": {
3
"message": "hello hello!"
4
}
5
}
Formula
REGEX_REPLACE(my_action.message, "h\w+", "goodbye")
Output
"goodbye goodbye!"
Example 2: Refer to capture groups by number
Input
1
{
2
"my_action": {
3
"name": "John Smith"
4
}
5
}
Formula
REGEX_REPLACE(my_action.name, "(\w+) (\w+)", "\2, \1")
Output
"Smith, John"
Example 3: Refer to named capture groups with `\k<name>`
Input
1
{
2
"my_action": {
3
"date": "2024-05-14"
4
}
5
}
Formula
REGEX_REPLACE(my_action.date, "(?<year>\d{4})-(?<month>\d{2})-(?<day>\d{2})", "\k<day>/\k<month>/\k<year>")
Output
"14/05/2024"
Sample actions
Select an action to inspect
You can also click "Copy actions" and paste them in your Tines story to see how they work.