Using regex to remove link but keep anchor text

Sometimes we need to remove anchors from html while displaying html content. You can easily remove links or anchors from a html content using PHP preg_replace with regex. Here is the complete code to remove anchors tags from a string.

$str = 'PHPZAG PHP <a href="" title="PHP">TUTORIALS</a> AND ARTICLES.';
echo preg_replace('#<a.*?>([^>]*)</a>#i', '$1', $str);

You may like these posts