我需要检索给定类的<p>
标签的内容。类可能是simplecomment
或comment
...RegEx问题 - 检索给定类的标签内容 - preg_match(_all)
所以我写了下面的代码
preg_match("|(<p class=\"(simple)?comment(.*)?\">)(.*)<\/p>|ism", $fcon, $desc);
不幸的是,它没有返回。但是,如果我删除了标记结束部分(<\/p>
),它会以某种方式起作用,使得字符串过长(从标记开始到文档结束)...
我的正则表达式有什么问题?
建议第三第三方替代[SimpleHtmlDom](http://simplehtmldom.sourceforge.net/)实际使用[DOM](http://php.net/manual/en/book.dom.php)而不是字符串分析:[phpQuery ](http://code.google.com/p/phpquery/),[Zend_Dom](http://framework.zend.com/manual/en/zend.dom.html),[QueryPath](http:/ /querypath.org/)和[FluentDom](http://www.fluentdom.org)。 – Gordon 2010-10-06 16:03:56