in reply to Re: position of first matching regex
in thread position of first matching regex

Yup. That is an excellent goof on my part. I should be good at goofs, I've practiced all my life.

My two lessons here are that: (@- != $-[0]) && $-[0] requires /...(...).../ re positional variables.

Thank you for your reply.


David

Replies are listed 'Best First'.
Re^3: position of first matching regex
by AnomalousMonk (Archbishop) on May 17, 2014 at 17:35 UTC
    ... $-[0] requires /...(...).../ re positional variables.

    You show a capturing group in your example and refer to "positional variables", so I thought I'd mention that  $-[0] is the offset of the start of the overall match and does not depend at all on capture groups.

    c:\@Work\Perl>perl -wMstrict -le "my $s = 'xxxabcyyy'; ;; print qq{overall match begining at offset $-[0] in '$s'} if $s =~ m{ abc }xms; " overall match begining at offset 3 in 'xxxabcyyy'

    (And BTW: I've been practicing goofs for quite a while myself.)