0

My goal is to obtain a regex expression that can get the attribute names and attribute values of pretty much any html tag. I'm currently using vuejs (which is the part that is making this tricky) and I'm having issues when the > char appears on conditions for example.

My current regex expression: (\S+)=["]?((?:.(?!["]?\s+(?:\s+)=|[>"]))+.)["]?

My string example:

<input type="text"
    class="form-control component-input-style"
    v-if="(!valueType || (valueType == 'email' || valueType == 'phone'))"
    v-model="currentValue"
    v-attr="data-min-length: minLength, data-max-length: maxLength, data-integer-only: integerOnly"
    v-class="disabled: disabled"
    size="{{ value && value > 10 ? value.length : 10 }}"
    v-on="keyup: detectKeystroke, keypress: filterValues, blur: onBlur, focus: onFocus">

What happens is that when the expression reaches the "size="{{ value && value > 10 ? value.length : 10 }}" it assumes that the > char is closing the tag when its not...

Does anyone find a fix for this regular expression?

thanks.

SSD
  • 1,373
  • 2
  • 13
  • 20
  • 11
    Good reading - https://stackoverflow.com/questions/1732348/regex-match-open-tags-except-xhtml-self-contained-tags/ – Alexei Levenkov Mar 20 '18 at 16:35
  • 1
    While [RegEx match open tags ...](https://stackoverflow.com/questions/1732348) is fun to read, it doesn't actually explain the problem or how to solve it. You want [How to use the HTML Agility Pack](https://stackoverflow.com/questions/846994/). – Dour High Arch Mar 20 '18 at 16:58
  • Possible duplicate of [How to use HTML Agility pack](https://stackoverflow.com/questions/846994/how-to-use-html-agility-pack) – wp78de Mar 22 '18 at 04:47

0 Answers0