The REGEXREPLACE() function replaces all matches of a regular expression with new text, to clean, normalize, or transform text.
Regex function name:
REGEXREPLACE()
Syntax
REGEXREPLACE(text, regular_expression, replacement)ℹ Calling function parameters in TimeTonic:
- $field_name = field (link, linked table column, number, selection, formula, text...).
- "free text" = free text to be added between quotation marks.
- do not use quotation marks for numbers.
Parameters
| Parameter | Description |
|---|---|
text |
Text in which parts will be replaced. |
regular_expression |
Search pattern used to identify the parts of the text to replace |
replacement |
(optional) Text that replaces each found occurrence. If not provided, occurrences are deleted. |
Example
1) Replace a word in a text (Supermarché → Hypermarché)
REGEXREPLACE("Supermarket", "Super", "Hyper")Result: "Hypermarket"
The role of the regex:
- "Super" → search pattern (here, simple text = this also works in Regex)
- "Hyper" → replacement text Result → each found occurrence is replaced.
2) Clean a phone number (keep only digits)
REGEXREPLACE("Tél : 06 12 34 56 78", "[^0-9]")Result: "0612345678"
The role of the regex:
- [^0-9] → “anything that is not a digit”
- (empty replacement) → removes these characters
- Result → only 0612345678 remains
Notes
- Works only on text.
- The replacement parameter is optional: if not provided, found occurrences are deleted.
- If no match is found, the function returns an empty value.
- ℹ️ The character \ and certain shortcuts (\d, \w, \s) are not supported.
See Introduction to REGEX() functions in TimeTonic for the complete usage rules.
Return type
The function returns text.
The output type format of the result can be configured in the output field options of the formula editor. For more details, see Output format options in the Formula column article.
Best practices
Use REGEXREPLACE() when: SUBSTITUTE() becomes insufficient, several variants need to be handled.
Text manipulation with Regex
| Function | Action | What is it for? |
|---|---|---|
| REGEXMATCH() | Validate | Check if a text matches a format or rule (returns true or false). |
| REGEXEXTRACT() | Extract | Retrieve specific information contained in unstructured text. |
| REGEXREPLACE() | Clean / transform | Dynamically replace or remove parts of a text according to a pattern. |