close
[root@XXXXXXX]# cat match.pl
#!/usr/bin/perl
$str ="time is money-is time" ;
print "$str\n";
if ($str =~ /\w+-/) #match " \w+- "
{
print "$`\n"; # time is
print "$&\n"; # money-
print "$'\n"; # is time
}
[root@XXXXXXX]# ./match.pl
time is money-is time
time is
money-
is time
[root@XXXXXXX]#
全站熱搜