【发布时间】:2011-05-19 12:58:09
【问题描述】:
我对正则表达式模式有疑问。结果它返回两个数组......这是我的代码:
$code = preg_match_all("/\< style\>(.*?)\<\/style\>/",$code,$matches);
var_dump($matches);
作为我设置的测试:
$code = ">< xxxxx> try blah fooo blah < /xxxxx> idfidf oh < x>< /x> < style> blah blah blah style1 < /style>< style>blah blah style 2 x< /style>
它返回 2 个数组,我的意思是
$matches = array
0 => array
0 => string '< style> blah blah blah style1 < /style>' (length=38)
1 => string '< style>blah blah style 2 x< /style>' (length=34)
1 => array
0 => string ' blah blah blah style1 ' (length=23)
1 => string 'blah blah style 2 x' (length=19)
我想要的匹配在第二个数组中。我在标签之间放了空格,因为编辑器没有显示 HTML 标签。
【问题讨论】:
标签: php regex preg-match