G
Gert Conradie
I need to list all the key/value pairs of and HTML tag. I already have
the complete tag as an text string.
For example: (Worst case scenario where standards was not followed in
the past)
<myTag key1="aaa" key2 = "bbb" key3='ccc' key4=444 key5= 555
key5="Please click here" >
I end up with two versions, each with its own flaw and I cant seems to
merge them:
A) Allow for no " or ' around values but fail when there is a space in
the attribute value:
\b(?<Keyword>[^>\s][\w]+)[\s]*=[\s]*[",']?(?<Value>[\w]*)[",']?
B)Allow for space in value of attribute but miss those without " or '
around the value.
\b(?<Keyword>[^>\s][\w]+)[\s]*=[\s]*[",']?(?<Value>[\w\s]*)[",']
This is my merge attempt that find all the key's and integer values,
but not the text values:
\b(?<Keyword>[^>\s][\w]+)[\s]*=[\s]*(?<Value>((?<!["'])[\d]+(?!["']))|((?<=["']?)[\w\s]*(?=["']?)))
Thanks in advance - help here would be much appreciated.
Gert
the complete tag as an text string.
For example: (Worst case scenario where standards was not followed in
the past)
<myTag key1="aaa" key2 = "bbb" key3='ccc' key4=444 key5= 555
key5="Please click here" >
I end up with two versions, each with its own flaw and I cant seems to
merge them:
A) Allow for no " or ' around values but fail when there is a space in
the attribute value:
\b(?<Keyword>[^>\s][\w]+)[\s]*=[\s]*[",']?(?<Value>[\w]*)[",']?
B)Allow for space in value of attribute but miss those without " or '
around the value.
\b(?<Keyword>[^>\s][\w]+)[\s]*=[\s]*[",']?(?<Value>[\w\s]*)[",']
This is my merge attempt that find all the key's and integer values,
but not the text values:
\b(?<Keyword>[^>\s][\w]+)[\s]*=[\s]*(?<Value>((?<!["'])[\d]+(?!["']))|((?<=["']?)[\w\s]*(?=["']?)))
Thanks in advance - help here would be much appreciated.
Gert