Reputation: 41
I want to remove all tag link from my site, except link containing xxx word in it.
Example:
<a class="happy" href="https://example.com/good-day/" rel="nofollo">happy day</a>
if the above code found, let it be replace with just text happy day
now if the below code if found and the link contain xxx in it, let it just leave it the way it is.
<a class="happy" href="https://example.com/good-day-xxx-now/" rel="nofollo">happy day</a>
so far the link contain xxx in it let it NOT be replace just just text.
I have tried the below regexes but it replaces all the content to just text
</?a(|\s+[^>]+)>
I TRIED TO USE THIS </?a(|\s+[^>]+^(?!.*xxx).*$)>
but i still could not achieve what i was looking for.
Upvotes: 1
Views: 2731
Reputation: 41
<a[^>]*href="(?:(?!\.mp3|\/tag\/)[^"])*"[^>]*(?:>|>[^<]*</a>)
<a[^>]*href="(?:(?!\.mp3|coco)[^"])*"[^>]*>([^<]*)<\/a>
credit goes to: @Aaron
Upvotes: 1