var str = '<img src="test>test" alt="test > test test" > "some text';
var reg = ???
How to make '<img src="test>test" alt="test > test test" >">'.match(reg)[0] === '<img src="test>test" alt="test > test test" >'
Tried this regexp /<s*(img)[^>]+(>[r|n|s]*</1>|/?>)/
, but not worked.
2
Answers
<img
– starting a tag[^">]*
– any number before the first"
(?:"[^"]+"[^">]*)*
– any number of"
pairs with no"
inside the pair plus any number of chars except"
and>
after the pair>
– closing