0

My query is not working as expected :

SELECT REGEXP_REPLACE('This is testing data SIL(TM)T for once ', 
'SIL(TM)T', 'SIL<REFERENCE ID="8208" TYPE="trademark"/>T')as 
Newdescriptiontext from dual

output should be:

This is testing data SIL<REFERENCE ID="8208" TYPE="trademark"/>T for once

which is not the case .Need guidance .

2 Answers 2

1

try replace instead of regexp_replace

SELECT REPLACE('This is testing data SIL(TM)T for once ', 
'SIL(TM)T', 'SIL<REFERENCE ID="8208" TYPE="trademark"/>T')as 
Newdescriptiontext from dual;
Sign up to request clarification or add additional context in comments.

1 Comment

Hi @schurik it is working but can you tell why it was not in regexp_replace.
1

You simply have to escape the parentheses:

SELECT REGEXP_REPLACE('This is testing data SIL(TM)T for once ', 
                       'SIL\(TM\)T', 'SIL<REFERENCE ID="8208" TYPE="trademark"/>T')as Newdescriptiontext
from dual

In a regexp, they are used to delimit a "subexpression", so '(TM)' matches 'TM'; if you escape them, they'll be interpreted as plain characters, thus having '\(TM\)' matching '(TM)'

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.