哎,求2个正则合并成一个正则怎么写啊,谢谢
本帖最后由 cluonani 于 2013-05-13 14:40:09 编辑 这是要匹配的内容
这个个正则,怎么合并成一个啊
我这样写不对
求高人指点
<br /><td class="LightRowHead"><br />Primary Color:<br /></td><br /><td class="LightRow"><br />Multi-Color<br /></td><br /></tr><br /><tr><br /><td class="DarkRowHead"><br />Multi Pack Indicator:<br /></td><br /><td class="DarkRow"><br />No<br /></td><br /></tr><br /><tr><br /><td class="LightRowHead"><br />Battery Type:<br /></td><br /><td class="LightRow"><br />Does Not Contain a Battery<br /></td><br /></tr><br />
这个个正则,怎么合并成一个啊
<br />$a = preg_match_all('/LightRowHead.*?>(.*?):.*?LightRow.*?>(.*?)</is', $content, $a);<br />$a = preg_match_all('/DarkRowHead.*?>(.*?):.*?DarkRow.*?>(.*?)</is', $content, $b);<br />我这样写不对
<br />$a = preg_match_all('/[LightRowHead|DarkRowHead].*?>(.*?):.*?[LightRow|DarkRow].*?>(.*?)</is', $content, $c);<br />求高人指点
分享到:
------解决方案--------------------
(xx
------解决方案--------------------
yy)
------解决方案--------------------
用方括号括起就变成字符单选了,要用圆括号
$a = preg_match_all('/(LightRowHead
------解决方案--------------------
DarkRowHead).*?>(.*?):.*?(LightRow
------解决方案--------------------
DarkRow).*?>(.*?)', $content, $LightRowHead);
不想加入向前引用的话可写作
$a = preg_match_all('/(?:LightRowHead
------解决方案--------------------
DarkRowHead).*?>(.*?):.*?(?:LightRow
------解决方案--------------------
DarkRow).*?>(.*?)', $content, $LightRowHead);
需要前后配对的话可写作
$a = preg_match_all('/(LightRow
------解决方案--------------------
DarkRow)Head.*?>(.*?):.*?\1.*?>(.*?)', $content, $LightRowHead);
------解决方案--------------------
(xx
------解决方案--------------------
yy)
------解决方案--------------------
用方括号括起就变成字符单选了,要用圆括号
$a = preg_match_all('/(LightRowHead
------解决方案--------------------
DarkRowHead).*?>(.*?):.*?(LightRow
------解决方案--------------------
DarkRow).*?>(.*?)', $content, $LightRowHead);
不想加入向前引用的话可写作
$a = preg_match_all('/(?:LightRowHead
------解决方案--------------------
DarkRowHead).*?>(.*?):.*?(?:LightRow
------解决方案--------------------
DarkRow).*?>(.*?)', $content, $LightRowHead);
需要前后配对的话可写作
$a = preg_match_all('/(LightRow
------解决方案--------------------
DarkRow)Head.*?>(.*?):.*?\1.*?>(.*?)', $content, $LightRowHead);

















