Say I have the following text
..(content).............
<A HREF="http://foo.com/content" >blah blah blah </A>
...(continue content)...
I want to delete the link and I want to delete the tag (while keeping the text in between). How do I do this with a regular expression (since the URLs will all be different)
Much thanks
Avoid regular expressions whenever you can, especially when processing xml. In this case you can use strip_tags()
or simplexml, depending on your string.
This will remove all tags:
preg_replace("/<.*?>/", "", $string);
This will remove just the <a>
tags:
preg_replace("/<\\/?a(\\s+.*?>|>)/", "", $string);