( my $str= "left center right" ) =~ /center/; print "\nLeft: <", substr( $str, 0, $-[0] ), ">\nMatch: <", substr( $str, $-[$#-], $+[$#-] - $-[$#-] ), ">\nRight: <", substr( $str, $+[$#+] ), ">\n"; __END__ This prints: Left: Match:
Right: < right>