in reply to Re^2: Finding the index of a string with a regexp
in thread Finding the index of a string with a regexp

Look at the arrays @- and @+, which point to the start resp. the end of submatches — use index 0 for the whole match. So you want $-[0].

Plus: unlike pos, it works without using /g, too.

You didn't really think Javascript could do something with regexps that Perl couldn't, did you? Where did you think its implementors got the ideas from, anyway?