Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:

Hello Monks,

I have looked @ perlre documentation but still not able to understand how they work.

Can someone tell me how it works by examples.

Replies are listed 'Best First'.
Re: Look ahead & Look behind
by toolic (Bishop) on Apr 03, 2010 at 00:23 UTC
Re: Look ahead & Look behind
by ikegami (Patriarch) on Apr 03, 2010 at 00:30 UTC
    Compare
    ( $_ = 'abcba' ) =~ s/b//g; # aca ( $_ = 'abcba' ) =~ s/bc//g; # aba ( $_ = 'abcba' ) =~ s/b(?=c)//g; # acba
    Compare
    ( $_ = '!a!b!c!' ) =~ s/!.!/!_!/g; # !_!b!_! ( $_ = '!a!b!c!' ) =~ s/!.(?=!)/!_/g; # !_!_!_! ( $_ = '!a!b!c!' ) =~ s/(?<=!).(?=!)/_/g; # !_!_!_!
Re: Look ahead & Look behind
by roboticus (Chancellor) on Apr 03, 2010 at 00:25 UTC

    Examples are all over the place. Why not look for them? Google and Super Search would be likely candidates. If you have a question about any of the specifics, let us know where you need help.

    ...roboticus

Re: Look ahead & Look behind
by Anonymous Monk on Apr 03, 2010 at 00:59 UTC
    But perlre includes examples