Help for this page
# first one my ($start, $middle, undef, $end) = $string =~ /^(.*?)(($pattern)+)(.* +?)$/g; # second one, with non-capturing parens -- I like it better my ($start,$middle,$end) = $string =~ /^(.*?)((?:$pattern)+)(.*?)$/g;
$pattern = 'AB'; 'BABABABBB' =~ ... print "$1<$2>$3$/"; __END__ prints "B<ABABAB>BB"