I have text file which contais several links and html formatted text (all tags under control). Want to filter it from all (text and html) using preg_replace. I want to keep links with anchor only.
Example of my file.
As I understand I need regexp to remove all exlude
As I understand I need regex to remove all excluding links tags and anchors. Suggest me regex, please.
Example of my file.
Code:
1337289282¶sentence, page 1¶<div class="postbody">
<div class="postdate">20.05</div>
<h2 class="panel"><a href="http://domain.com/page.html">Anchor</a></h2>
<div class="anoncetxt"> Text ... text</div>
<div class="postdate">21.05</div>
<h2 class="panel"><a href="http://domain.com/page.html">Anchor2</a></h2>
<div class="anoncetxt"> Text ... text</div>
</div>
As I understand I need regexp to remove all exlude
Code:
<a href="http://domain.com/page.html">Anchor</a>
<a href="http://domain.com/page.html">Anchor2</a>
As I understand I need regex to remove all excluding links tags and anchors. Suggest me regex, please.