Reputation: 75
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 .
Upvotes: 0
Views: 933
Reputation: 22949
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)'
Upvotes: 1
Reputation: 7928
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;
Upvotes: 1