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]#

arrow
arrow
    全站熱搜
    創作者介紹
    創作者 hweily 的頭像
    hweily

    hweily

    hweily 發表在 痞客邦 留言(0) 人氣()