c:\@Work\Perl\monks>perl -wMstrict -le "my $s = 'foobar'; ;; print qq{positive look-behind capture: '$1'} if $s =~ m{ (?<= (foo)) bar }xms; print qq{positive look-ahead capture: '$1'} if $s =~ m{ foo (?= (bar)) }xms; " positive look-behind capture: 'foo' positive look-ahead capture: 'bar' #### c:\@Work\Perl\monks>perl -wMstrict -MData::Dump -le "my $s = 'abcd efgh'; ;; my @caps = $s =~ m{ \w+ }xmsg; dd 'non-overlapping captures: ', \@caps; ;; @caps = $s =~ m{ (?= (\w+)) }xmsg; dd 'overlapping captures: ', \@caps; " ("non-overlapping captures: ", ["abcd", "efgh"]) ( "overlapping captures: ", ["abcd", "bcd", "cd", "d", "efgh", "fgh", "gh", "h"], )