views:

751

answers:

1

Is there an existing PL/SQL method which takes a string and returns the same string but with backslashes preceding any regexp chars?

+2  A: 

Try this:

result := REGEXP_REPLACE(subject, '([$^[()+*?{\|])', '\\\1', 1, 0, 'c');
Jan Goyvaerts
Correct me if I'm wrong I think those REGEXP_ functions are 10g only? Amnyway for Ora9 I used:owa_pattern.change(strResult,'[+,.,(,)[,*,\,^,$,|,?,{,#]','\\' || '
alansk
REGEXP functions are new in 10g. Since the question is about regular expressions, I assumed you were working with 10g. You didn't say.
Jan Goyvaerts
Never assume ;) Seriously tho, sorry about not mentioning the Oracle version.
alansk