..(content).............
<A HREF="http://test.com/content" >test link </A>
...(continue content)...
I want to delete link with content. And also text between link.
..(content).............
<A HREF="http://test.com/content" >test link </A>
...(continue content)...
I want to delete link with content. And also text between link.
While regular expressions can be used to do this, they will be prone to problems. A more robust solution is using the DOM extension or another HTML parser to remove the a
element in question. Or all a
elements, for that matter. If you really want to do this with a regular expression, the following should work:
preg_replace('/<A (.*?)>(.*?)</A>/i', '', $data);
I wouldn't use regex here at all - rather DOMDocument::loadHTML, then DOMDocument::getElementsByTagName and DOMNode::removeChild; finally DOMDocument::saveHTML