0
我想改进我的代码,但我不知道如何编写正则表达式。PHP:preg_match_all none xhtml attributes
我想要在标签中获取所有非xhtml属性。
所以预浸比赛后,我想:
array(
0 => "required",
1 => "autocomplete"
);
$balise = <input id="myId" class="myClassA myClassB myClassC" required autocomplete/>;
实际上我用这个preg_match_all("/(?<=\s)[\w]+(?=[\s\/>])/i", $balise, $attributs);
但与正则表达式,我得到:
array(
0 => "myClassB",
1 => "required",
3 => "autocomplete"
);
我不想得到myClassB
...
任何人都可以帮我写我的正则表达式吗?
THX
你可以发布你正在使用正则表达式的原始数据吗('$ balise')吗? – Pietu1998
使用解析器解析HTML,而不是正则表达式 – user4035
已编辑。 simplyParseXML是不是完全理解HTML,不? – Jordan