Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

PL/SQL function to return string with regexp special chars escaped

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

like image 562
alansk Avatar asked Jun 22 '26 11:06

alansk


1 Answers

Try this:

result := REGEXP_REPLACE(subject, '([$^[()+*?{\|])', '\\\1', 1, 0, 'c');
like image 148
Jan Goyvaerts Avatar answered Jun 24 '26 04:06

Jan Goyvaerts