Skip to Main Content

SQL & PL/SQL

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

How to implement negative lookahead in Oracle

2633028Mar 17 2014 — edited Mar 17 2014

I need to find all occurrences of <a href="somelinke" someattributes > in a text stored in columna and replace it with <a href="somelink" someattributes RRRR> where 'RRRR' is my new attribute. If there is occurence of <a href="somelink" someattributes RRRR>, I do not want to insert another 'RRRR' as it already has it. I just need to leave it. I used negative lookahead regular expression in Java and made it work. But same regular expression doesn't work. Here is what worked in Java and doesn't work in Oracle.

select REGEXP_REPLACE(datacol,'(<a\s+[^>]*href="[^>](?:(?!RRRR).)*?)(>)','\1 "rel=nofollow" \3') from table.

Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Apr 14 2014
Added on Mar 17 2014
2 comments
1,697 views