/m (^) ... ($) \n (^) ... ($)
/s (^) ... $ (\n) ^ ... ($)
/ms (^) ... ($) (\n) (^) ... ($)
(\A) ... \n ... (\Z) \n
(\A) ... \n ... (\z)
###
havoc without [ms]:
#!/usr/bin/perl
$str = "abc\ndef\nghi";
print 'NO [m] [s]: ';
if ( $str =~ m/^(\w{1}).*(\w{1})$/ )
{
print "$1::$2";
}
print "\n";
print '[m]: ';
if ( $str =~ m/^(\w{1}).*(\w{1})$/m )
{
print "$1::$2";
}
print "\n";
print '[s]: ';
if ( $str =~ m/^(\w{1}).*(\w{1})$/s )
{
print "$1::$2";
}
print "\n";
# s/// is ok (/s by default)
print "[change]: \n";
$str =~ s/def//;
print "$str\n";
No comments:
Post a Comment