REGEXP_REPLACE

functionsupportedCore SQL functions

docs.snowflake.com ↗

String functions (regular expressions)

Returns the subject with the specified pattern — or all occurrences of the pattern — either removed or replaced by a replacement string.

Syntax

supportedpartialnot supportednot scored

 REGEXP_REPLACE( <subject> ,
                 <pattern>
                   [ , <replacement>
                     [ , <position>
                       [ , <occurrence>
                         [ , <parameters> ]
                       ]
                     ]
                   ]
)

Parameters

NameRequiredDescription
subjectrequiredThe string to search for matches.
patternrequiredPattern to match. For guidelines on specifying patterns, see String functions (regular expressions).
replacementoptionalString that replaces the substrings matched by the pattern. If an empty string is specified, the function removes all matched patterns and returns the resulting string. Default: '' (empty string).
positionoptionalNumber of characters from the beginning of the string where the function starts searching for matches. The value must be a positive integer. Default: 1 (the search for a match starts at the first character on the left)
occurrenceoptionalSpecifies which occurrence of the pattern to replace. If 0 is specified, all occurrences are replaced. Default: 0 (all occurrences)

Returns

Returns a value of type VARCHAR. When the 2026_04 BCR bundle is enabled and the subject is collated, the subject’s collation propagates to the return value; apply COLLATE '' to the subject to get an uncollated result. If no matches are found, returns the original subject. Returns NULL if any argument is NULL.

Usage notes

Collation details

When the 2026_04 BCR bundle is enabled, the function accepts arguments with a collation specification. The collation has no effect on pattern matching: matching is always case-sensitive unless you pass the i flag in the parameters argument.