我编写了一个RegEx来查找div标签属性和值,但它有以下问题。寻找指导和帮助
attr="a s"
attr='as'
这是我的regEx
/\b([^\s]+)(="(^'|^"|[^\s]+)*")/ig
以上regEx有3组
第一组结果=属性键名
第二组结果= =
第3组结果=没有"
的属性值
html标签示例
<div json="{"key1":"value1","key2":{"key3":"value3","key4":"value4","key5":"value5","key6":"value6","key7":"value7","key8":"value8"}"
data='sdaasd'
data-role=""
key="somekey">
示例带空格的html标记
<div json="{"key1":"value1","key2": {"key3":"value3", "key4":"value4","key5":"value5","key6":"value6","key7":"value7","key8":"value8"}"
data='sdaasd'
data-role=""
key="somekey">