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

31 Dec , 2011  

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 :

preg_replace('/<a[^>]*>(.*)</a>/iU','', $text);

Or seconds alternative is :

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 *