REGEX_REPLACE_ALL
All functions > STRING > REGEX_REPLACE_ALL
Returns the string with all occurrences of a regular expression pattern replaced.
Signatures
Returns: String with all matches replaced
REGEX_REPLACE_ALL(string: VARCHAR, pattern: VARCHAR, replacement: VARCHAR) → VARCHAR sql
| Parameter | Type | Required | Description |
|---|---|---|---|
string | VARCHAR | Yes | String to search in |
pattern | VARCHAR | Yes | Regular expression pattern to match |
replacement | VARCHAR | Yes | Replacement string (supports backreferences like \1) |
Notes
- All non-overlapping matches are replaced
- Supports backreferences in the replacement string (\1, \2, etc.)
- If the pattern does not match, returns the original string unchanged
- Use REGEX_REPLACE_FIRST to replace only the first occurrence
Examples
FeatureQL
SELECT
f1 := REGEX_REPLACE_ALL('abc123def456', '[0-9]+', 'NUM'), -- Replace all digit groups
f2 := REGEX_REPLACE_ALL('foo bar foo', 'foo', 'baz'), -- All occurrences replaced
f3 := REGEX_REPLACE_ALL(' extra spaces ', '\s+', ' '), -- Normalize whitespace
f4 := REGEX_REPLACE_ALL('no match', '[0-9]+', 'X') -- No match returns original
;Result
| f1 VARCHAR | f2 VARCHAR | f3 VARCHAR | f4 VARCHAR |
|---|---|---|---|
| abcNUMdefNUM | baz bar baz | extra spaces | no match |
On this page