页面:http://wenwen.soso.com/z/q87133532.htm我要取出第一满意答案的内容。
我的正则是:preg_match_all("|<div class=\"answer_con\">\s*<pre>(.*)</pre></div>|isU", $text_body,$con);
——这样取不出来文本preg_match_all("|<div class=\"answer_con\">(.*)</div>|isU", $text_body,$con);
——这样可以取到要的内容,但是文本的头属的标签<pre>也搞进来了,这个我不想要而且文本开始还有空格也不想要
我的正则是:preg_match_all("|<div class=\"answer_con\">\s*<pre>(.*)</pre></div>|isU", $text_body,$con);
——这样取不出来文本preg_match_all("|<div class=\"answer_con\">(.*)</div>|isU", $text_body,$con);
——这样可以取到要的内容,但是文本的头属的标签<pre>也搞进来了,这个我不想要而且文本开始还有空格也不想要
echo $con[1];
preg_match_all("#<div class=\"answer_con\">[^<]*<pre>\s*(.*?)</div>#isU", $text_body,$con);没试过,不过估计得行