Wednesday, May 8, 2019

php - Remove links where href is disallowed

I have some links like this:



legal


I want to remove all links that does not have "legallink.com" in it. But still keep the content. So the above input would output:



legal



It should work recursively through the links.



I found this regex that removes all links: /<\\/?a(\\s+.*?>|>)/, but I want it to keep links where href is legallink.com.



Can this be done with regex? Or should I use a DOM parser?

No comments:

Post a Comment

plot explanation - Why did Peaches&#39; mom hang on the tree? - Movies &amp; TV

In the middle of the movie Ice Age: Continental Drift Peaches' mom asked Peaches to go to sleep. Then, she hung on the tree. This parti...