I have written a RegEx to find div tag attributes and value but it have following issues. looking for guide and help
- suppose white space added in attributes value then it broken, i.e -
attr="a s"
- suppose attribute value given with ' without " then it broken, i.e -
attr='as'
- suppose any new line break in attribute value then it broken
here is my regEx
/\b([^\s]+)(="(^'|^"|[^\s]+)*")/ig
above regEx have 3 groups
1st group result = attribute key name
2nd group result = value after =
3rd group result = attribute value without "
html tag sample
<div json="{"key1":"value1","key2":{"key3":"value3","key4":"value4","key5":"value5","key6":"value6","key7":"value7","key8":"value8"}"
data='sdaasd'
data-role=""
key="somekey">
sample html tag with space
<div json="{"key1":"value1","key2": {"key3":"value3", "key4":"value4","key5":"value5","key6":"value6","key7":"value7","key8":"value8"}"
data='sdaasd'
data-role=""
key="somekey">