LOL! I have NO IDEA what this does. :) j https://gist.github.com/1237698 use 5.14.1; my $str = q {This is the best thing ever.}; my $re = qr{(.i.) .+? (.e.)}; $str =~ $re; for (1 .. $#-) { my $substr = substr $str, $-[ $_ ], $+[ $_ ] - $-[ $_ ]; printf "match %s (from %2s to %2s): %s\n", $_, $-[ $_ ], $+[ $_ ], $substr; }