Yash
Yash

Reputation: 39

Replace string between characters using regx_replace

I have one column , which contain values like - $test test12$ test14 I have to update the value the between $$. like-$test done$ test14

I have tried to solve this by using :-

select REGEXP_REPLACE('$test test12$ test14','$(.*?)$','test done') from dual

But not working

Given String -$test test12$ test14 Expected result - $test done$ test14

Upvotes: 0

Views: 67

Answers (1)

Tim Biegeleisen
Tim Biegeleisen

Reputation: 521674

The character $ is a rexeg metacharacter, which has a special meaning (it means the end of the input or current line). It you want to target literal $, then it needs to be escaped:

SELECT
    REGEXP_REPLACE('$test test12$ test14', '\$(.*?)\$','$test done$')
FROM dual;

The above outputs:

$test done$ test14

Upvotes: 3

Related Questions