alansk
alansk

Reputation: 33

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?

Upvotes: 3

Views: 1675

Answers (1)

Jan Goyvaerts
Jan Goyvaerts

Reputation: 21999

Try this:

result := REGEXP_REPLACE(subject, '([$^[()+*?{\|])', '\\\1', 1, 0, 'c');

Upvotes: 1

Related Questions