So I'm trying to modify a RegEx to capture tags inside an HTML-Anchor element (I know you're not supposed to, but it is demanded). But a problem arose when I tried to to not match anything inbetween the capture-groups since the "anything" is taken literally and so the tags inside the element aren't captured. Until now I have tried a non-capturing group and a negated set but both seem to "swallow" my groups.
/<a[^>]*href=\"([^\"]+)\"(?:.*?)( data-survey=[\"\']({[^}]*})[\"\'])?( data-answer=[\"\']({[^}]*})[\"\'])?[^>]*\/?>/g
The (?:.*?)
seems to be the culprit here. For example: <a href="#" foo data-survey="{...}">
. As long as there isn't anything inbetween the <a
and the data...
it seems to be working.