Can anyone look at my regex in javascript and suggest a correct one?
I'm trying to select attributes(name/value) pairs in an HTML/XML string like following?
<unknowncustom:tag attrib1="XX' XX'" attrib2='YY" YY"' attrib3=ZZ""'>/unknowncustom:tag>
SOME TEXT that is not part of any tag and should not be selected, name='XX', y='ee';
<custom:tag attrib1="XX' XX'" attrib2='YY" YY"' attrib3=ZZ""'>/custom:tag>
I found many solutions but none seem foolproof (including this one Regular expression for extracting tag attributes)
My current regex selects the first attribute pair but can't figure out how to make it select all matching attributes. Here is the regex:
/<\w*:?\w*\s+(?:((\w*)\s*=\s*((?:(?:"[^"]*")|(?:'[^']*')|[^>\s]+))))[^>]*>/gim
Thanks