Preg_replace regex delete tags link url completely with text inside using php


We need to completely remove anchor links with text inside using PHP. Then, we can use preg_replace() and removing all tags links with string completely by :

1
preg_replace(‘/<a[^>]*>(.*)</a>/iU’,”, $text);

Or seconds alternative is :

1
preg_replace(‘#(<a.*?>).*?(</a>)#’, ”, $text);

Now you can remove / delete all anchor links 🙂


Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.