Regular expressions (Regex) allow you to analyze, clean, or validate text directly in your TimeTonic formulas, without using Excel or external scripts.
They are particularly useful for:
- Securing user entries
- Cleaning imported data (CSV, API)
- Validating formats (codes, numbers, identifiers).
TimeTonic offers 3 Regex functions
| Function | What it’s for |
|---|---|
| REGEXMATCH() | Check if a text matches a format |
| REGEXEXTRACT() | Extract specific information from a text |
| REGEXREPLACE() | Clean or transform a text |
Each function is detailed in its dedicated article.
Important Rules to Know
Before using regular expressions in TimeTonic, follow these rules to ensure stable and compatible formulas.
1. Use explicit patterns
Favor explicit character classes rather than shortcuts.
Recommended examples:
-
[0-9]→ digit -
[A-Z]→ uppercase letter -
[A-Za-z]→ lowercase and uppercase letters -
[A-Za-z0-9]→ alphanumeric characters
Explicit patterns are more readable and avoid interpretation ambiguities.
2. Understand repetition operators
The following operators allow you to repeat a pattern:
-
+→ one or more occurrences -
*→ zero or more occurrences -
{n}→ exactly n occurrences
When an operator needs to apply to several characters, use parentheses to group the pattern.
Example:
([0-9]+){5}Without parentheses, the repetition may apply only to the last element.
3. Escape character not supported
The character \ is not supported in TimeTonic.
Therefore, the following shortcuts should not be used:
\d\D\w\W\s
Use the explicit equivalents:
-
\d→[0-9] -
\D→[^0-9] -
\w→[A-Za-z0-9] -
\W→[^A-Za-z0-9]
This writing ensures compatibility with the Regex engine used by TimeTonic.
4. Character classes
Brackets [] define a set of allowed characters.
Examples:
-
[ABC]→ matches A or B or C -
[^0-9]→ matches any character except a digit
The symbol ^ placed at the beginning of a class means exclusion.
5. Using metacharacters
To insert a metacharacter such as:
.*+$
You must write it in brackets.
Example:
[.] [*] [+] [$]
This allows you to search for the character itself, not its regex meaning.
These rules ensure stable and compatible formulas with TimeTonic.
Examples of Business Use Cases
Remove all non-numeric characters:
REGEXREPLACE([Téléphone], "[^0-9]")
Before: Tel : 06 12 34 56 78
After: 0612345678
What it does:
- [^0-9] → anything that is NOT a digit
- (empty replacement) → removes found characters
Result: only the digits remain.
Validate a code that contains at least one UPPERCASE letter AND a series of 5 consecutive digits. Example: "here is the reference code T51234"
REGEXMATCH([Code], "([A-Z].*([0-9]){5}")
What it does:
- [A-Z] → at least one uppercase letter
- * → anything between the two
- ([0-9]){5} → 5 consecutive digits
Result = TRUE if both conditions are present in the text, otherwise FALSE
Automatically retrieve this number in a dedicated field.
Example: "Hello, my order 45821 has not been delivered."
REGEXEXTRACT([Message client], "[0-9]+")
What it does:
- [0-9]+ → extracts the first sequence of consecutive digits
- * → No matter the position of the number in the text
Result = 45821
To go further
=> See the dedicated articles for each function:
REGEXMATCH() – Checks if a pattern is present (true / false)
REGEXEXTRACT() – Retrieves the found value
REGEXREPLACE() – Edits the source text