This function replaces the matching pattern with a specified replace_string, allowing complex search-and-replace operations.
Syntax:
REGEXP_REPLACE(source_string, pattern[, replace_string [, position[,occurrence, [match_parameter]]]])
Example:
The following query replaces any two or more spaces with a single space. The ( ) subexpression contains a single space, which can be repeated two or more times, as indicated by {2,}.
Expand|Select|Wrap|Line Numbers
- SELECT REGEXP_REPLACE('Joe Smith',
- '( ){2,}', ' ')
- AS RX_REPLACE
- FROM dual
- RX_REPLACE
- ----------
- Joe Smith