当前位置: 代码迷 >> PHP >> 求一正则表达式,婚配一个限定的id
  详细解决方案

求一正则表达式,婚配一个限定的id

热度:22   发布时间:2016-04-28 23:00:30.0
求一正则表达式,匹配一个限定的id
<table id="forum_list" cellspacing="0" style="width:760px;">  匹配这个id!
------最佳解决方案--------------------
$s='你的串';
preg_match('/<table id="forum_list"[^>]*>(.*?)<\/table>/s',$s,$m);
echo $m[1]; 
------其他解决方案--------------------
/ id="([^"]*)"/
------其他解决方案--------------------
引用:
/ id="([^"]*)"/
  匹配forum_list这个固定ID
------其他解决方案--------------------
引用:
/ id="([^"]*)"/
匹配forum_list这个固定ID 以及下面的所有内容!
------其他解决方案--------------------
那个id看上去像discuz的
------其他解决方案--------------------
如果是匹配大堆html内容,最好把内容装载进dom,用dom的方式处理dom