in reply to [perlre] \G with /gc does not catch last match for me

The \G meta-character specifies the zero width point after which the last global match left off, in your case, after the 22. So, you're left at 'a44' and trying to match \d\d which of course does not match. If you were instead to go with...

$_ = "1122a44"; print $1, "\n" while /(\d\d)/g;

then you would get the effect that you are seeking.

Replies are listed 'Best First'.
Re: Re: [perlre] \G with /gc does not catch last match for me
by princepawn (Parson) on Aug 05, 2003 at 17:53 UTC
    Oooooooooooooooooohhhhhh.... it an aaaaaaaaaaaaaaaaaanchor...... I get it.... .thanks! :)

    Carter's compass: I know I'm on the right track when by deleting something, I'm adding functionality

      Oooooooooooooooooohhhhhh.... it an aaaaaaaaaaaaaaaaaanchor...... I get it.... .thanks! :)

      You put 'perlre' in the node title. How about reading it? :)

      Juerd # { site => 'juerd.nl', plp_site => 'plp.juerd.nl', do_not_use => 'spamtrap' }