Greg- This question was answered on Stack Overflow: http://stackoverflow.com/questions/87380/how-can-i-find-the-location-of-a-regex-match-in-perl
<http://stackoverflow.com/questions/87380/how-can-i-find-the-location-of-a-regex-match-in-perl>brian d foy's answer seems to be the best: The built-in variables @- and @+ hold the start and end positions, respectively, of the last successful match. $-[0] and $+[0] correspond to entire pattern, while $-[N] and $+[N] correspond to the $N ($1, $2, etc.) submatches. -Conor On Thu, Apr 14, 2011 at 10:38 AM, Greg Aiken <[email protected]>wrote: > given how smart perl is, I was thinking there must be a function within > perl whereby if one does a pattern match against a scaler, that in addition > to having regex being able to return such built in vars as: $` (what > preceeds the match), $’ (what follows the match), $1, etc… > > > > is there a built in var that returns the position within the scalar where > the match occurred? > > > > of course, if not, one may always evaluate length($`). > > > > I was just curious > > _______________________________________________ > Perl-Win32-Users mailing list > [email protected] > To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs > >
_______________________________________________ Perl-Win32-Users mailing list [email protected] To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs
