Much of the regex here did not help me. Some of it removes the content inside the anchor (which is not at all what OP asked for) and not all of the content at that, some of it will match any tag beginning with a, etc.
This is what I created for my needs at work. We had an issue where passing HTML to wkhtmltopdf that had anchor tags (with many data attributes and other attributes) would sometimes prevent the PDF from producing, so I wanted to remove those while keeping the text.
Regex:
/</?a( [^>]*)?>/ig
In PHP you can do:
$text = "<a href='http://www.google.com/'>Google1</a><br>" .
"<a>Google2</a><br>" .
"<afaketag href='http://www.google.com'>Google2</afaketag><br>" .
"<afaketag>Google4</afaketag><br>" .
"<a href='http://www.google.com'><img src='someimage.jpg'></a>";
echo preg_replace("/<\/?a( [^>]*)?>/i", "", $text);
Outputs:
Google1<br>Google2<br><afaketag href='http://www.google.com'>Google2</afaketag><br><afaketag>Google4</afaketag><br><img src='someimage.jpg'>