1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
#!perl use strict; use warnings; my $str = <<EOT; first second third EOT for my $re ( qr/^(.*?)$/, qr/^(.*?)$/m, qr/^(.*?)$/s, qr/^(.*?)$/ms ) { my $s = $str; print "\$re = $re\n"; $s =~ s{$re}{print "<$1>"}eg; print "\n"; }
1 2 3 4 5 6 7 8 9 10
$re = (?-xism:^(.*?)$) $re = (?m-xis:^(.*?)$) <first><second><third> $re = (?s-xim:^(.*?)$) <first second third> $re = (?ms-xi:^(.*?)$) <first><second><third>