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