Using backreference: REGEXP_REPLACE('H1234 H4321 H2345','(.*) (.*) (.*)','\3, \2 \1') : Group « Regular Expressions « Oracle PL / SQL






Using backreference: REGEXP_REPLACE('H1234 H4321 H2345','(.*) (.*) (.*)','\3, \2 \1')


SQL> --For a better example of using backreference, let's suppose we wanted to convert a 
name in the form "first middle last" into the "last, middle first" format. Consider this command:
SQL>
SQL> SELECT REGEXP_REPLACE('H1234 H4321 H2345','(.*) (.*) (.*)','\3, \2 \1')FROM dual;

REGEXP_REPLACE('H1
------------------
H2345, H4321 H1234

SQL>
SQL>
           
       








Related examples in the same category

1.Group the letters 'ir' together by putting them in parentheses
2.Parenthesize both expressions
3.REGEXP_SUBSTR('Yababa dababa do','(ab)')
4.REGEXP_SUBSTR('Yababa dababa do','(ab)\1'), backreference option