David
David

Reputation: 11

PHP Regex - Find url and text in html anchor tags

Hi there I was wondering whether someone know how to remove both the url and the link text from all anchor tags in a big paragraph of text. once remove if I could store them in an array for later use.

Im sure this is possible but I really struggle with regex.

Hopefully there is someone out there who has came across this before or who has some good knowledge on this.

Thank you

Upvotes: 1

Views: 1137

Answers (1)

Citizen
Citizen

Reputation: 12937

Regex wasn't really designed to be a perfect html parser. Have you tried doing a simpleXML load string?

http://php.net/manual/en/function.simplexml-load-string.php

But for regex, check out these:

What's the best way to remove <br> tags from the end of a string?

How to convert multiple <br/> tag to a single <br/> tag in php

Upvotes: 1

Related Questions