tags:

views:

47

answers:

1

In Oracle's regexp_replace function, there is a parameter replace_string in which you can specify backreferences \1 to \9.

Is there a way to refer to backreferences after the 9th one? Oracle treats \10 as \1 followed by a literal 0.

+5  A: 

Nope, nine is the max.

\n

Backreference

Matches the nth preceding subexpression, that is, whatever is grouped within parentheses, where n is an integer from 1 to 9.

-- http://download.oracle.com/docs/cd/E11882%5F01/appdev.112/e10471/adfns%5Fregexp.htm#ADFNS1013

Note that this is not an Oracle limitation. Many (most?) regex implementations' maximum is nine.

Bart Kiers
+1 for pointer oracle documentation, looks like this is still the same in 11gR2 as wellhttp://download.oracle.com/docs/cd/E11882_01/appdev.112/e10471/adfns_regexp.htm#ADFNS1013
carpenteri
Re: not an Oracle limitation. While it's true that not many regex engines understand \10, a number understand $10 or ${10} (e.g. Java, Perl, PHP, .NET). I was wondering if there was such an alternative syntax in Oracle. It looks like there isn't.
Simon Nickerson
@simonn, thanks for the info. I didn't know that of Java.
Bart Kiers