use regular expression in php
..(content).............
<A HREF="http://test.com/content" >test link </A>
...(continue 开发者_如何学Pythoncontent)...
I want to delete link with content. And also text between link.
I wouldn't use regex here at all - rather DOMDocument::loadHTML, then DOMDocument::getElementsByTagName and DOMNode::removeChild; finally DOMDocument::saveHTML
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);
精彩评论