Name
\1 through \9 (Backslash) — References the value matchedby a preceding subexpression
Synopsis
Use \1
, \2
, \3,
etc
. through \9
to create backreferences
to values matched by preceding subexpressions. You can backreference
up to nine subexpressions, the first nine, in any expression.
Subexpressions are numbered in the order in which their opening
parentheses are encountered when scanning from left to right.
For example, to flip a name from last, first format to first last:
SELECT REGEXP_REPLACE(
'Sears, Andrew',
'(.+), (.+)','\2 \1')
FROM dual;
Andrew Sears
For more examples, see Section 1.6.8 in Section 1.6 and REGEXP_REPLACE under Section 1.9.
Get Oracle Regular Expressions Pocket Reference now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.