I wrote a regex for finding id values of html elements:
<.+ id\s*=\s*["'](.+)["'].*/?>
For most cases it returns id values, but not for this one:
<input type="hidden" name="__EVENTTARGET" id="__EVENTTARGET" value="" />
It matches the following group value:
__EVENTTARGET" value="
instead of the expected __EVENTTARGET.
What is wrong in the regex?
Your expression
(.+)is “greedy” — it matches as much as it can.There are 2 solutions:
“Lazy” (non-greedy): this will match as few characters as possible
or a better solution, instead of matching
.you should match[^'"]: