Search notes:

ORA-12727: invalid back reference in regular expression

Ok:
select
   regexp_substr('foo bar baz', 'foo bar (\w*)', '\1')
from
   dual;
Also ok, although \2 references a group that does not exist in the pattern.
select
   regexp_replace('foo bar baz', 'foo bar (\w*)', '\2')
from
   dual;
Also ok:
select
   regexp_replace('abc def ghi ghi jkl', '.* (\w+) \1.*', '\1')  ghi
from
   dual;
This causes ORA-12727: invalid back reference in regular expression because \2 references a group that is not defined in the pattern.
select
   regexp_replace('abc def ghi ghi jkl', '.* (\w+) \2.*', '\1')  ghi
from
   dual;

See also

Other Oracle error messages

Index