You're conflating two distinct concepts: capturing and consuming. Regexes normally consume whatever they match; that's just how they work. Additionally, most regex flavors let you use capturing groups to pluck out specific parts of the overall match. (The overall match is often referred to as the zero'th capturing group, but that's just a figure of speech.)
It sounds like you're trying to match a whole tag, but only consume the final
>
. That's not possible in most regex flavors, JavaScript included. But if you're using Perl or PHP, you could use \K
to spoof the match start position:
(?i)]+?href="http://[^"]+"[^>]*\K>
And in .NET you could use a lookbehind (which, like a lookahead, matches without consuming):
(?i)"(?<=]+?href="http://[^"]+"[^>]*)>
Of the other flavors that support lookbehinds, most place restrictions on them that render them unusable for this task.