user2710603
user2710603

Reputation: 345

XPath/XQuery Regular Expression replacing a String pattern

I have following xml to read:

<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!DOCTYPE PROCESS_PO_007 SYSTEM "003_process_po_007.dtd">
<!-- Oracle eXtensible Markup Language Gateway Server  -->
<PROCESS_PO_007>
  <CNTROLAREA>..

I want to replace any comments in input xml by single space. I want to replace any tag starting with and the string in-between with a space e.g

<!DOCTYPE PROCESS_PO_007 SYSTEM "003_process_po_007.dtd"> should be replaced by ' ' similarly <!-- Oracle eXtensible Markup Language Gateway Server --> should be replace by ' '

I am using following replace function but not successful:

replace(tab.user_data.payload, '&lt;!.*?&gt;', ' ')

but this is not working.

Can anyone suggest what am I doing wrong here.

Upvotes: 0

Views: 1295

Answers (1)

schurik
schurik

Reputation: 7928

you have to use regexp_replace instead of replace, if you want to make a use of regular expressions

select regexp_replace('<!-- Oracle ...  -->blub', '<!.*?>', ' ') from dual

Upvotes: 1

Related Questions