Skip to content

Instantly share code, notes, and snippets.

@rjbs
Created September 23, 2011 15:42
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rjbs/1237698 to your computer and use it in GitHub Desktop.
Save rjbs/1237698 to your computer and use it in GitHub Desktop.
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;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment