Replacing Text in Strings
AMPS provides a pair of functions, REPLACE
and REGEXP_REPLACE
, that replace text within strings. The REPLACE
function does a literal match of the string to be replaced, while REGEXP_REPLACE
uses a PCRE pattern to find the string to be replaced.
The following expressions all evaluate as true:
REPLACE('fandango', 'dan', 'din') == 'fandingo'
REGEXP_REPLACE('fandango','n.*n', 'r') == 'fargo'
Function
Parameters
Description
REPLACE
string to transform, string to match, replacement text
Returns the input string, with all occurrences of the string to match replaced with the replacement text.
REGEXP_REPLACE
string to transform, pattern to match, replacement text
Returns the input string, with all occurrences of the pattern to match replaced with the replacement text.
Last updated