我正在尝试解析 php.ini 中的 HTML 标签属性字符串。可以有3种情况:
attribute="value" //inside the quotes there can be everything also other escaped quotes
attribute //without the value
attribute=value //without quotes so there are only alphanumeric characters
有人可以帮我找到一个正则表达式,它可以在第一个匹配属性名称,在第二个匹配属性值(如果存在)?
永远不要使用正则表达式来处理 html https://stackoverflow.com/questions/1357357/regexp-to-add-attribute-in-any-xml-tags/1357393#1357393, 尤其如果您正在编写一个库并且不知道您的输入会是什么样子。看一眼简单XML http://php.net/manual/en/simplexmlelement.construct.php, 例如。
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)