perl 怎么通过变量进行模式匹配?
原来的匹配程序是这样的,$Part_1="111122223333";print$Part_1;print"\n";$Part_1=~/(\d{4})(\d{4})(\d...
原来的匹配程序是这样的,
$Part_1 = "111122223333";
print $Part_1;
print "\n";
$Part_1 =~ /(\d{4})(\d{4})(\d{4})/;
$Current_Bit = $1;
print $Current_Bit;
$Current_Bit = $2;
print $Current_Bit;
$Current_Bit = $3;
print $Current_Bit;
其中我想把匹配模式存到变量中进行匹配,例如:
$ref = '(\d{4})(\d{4})(\d{4})';
$Part_1 =~ /$ref/;
可是我不知道改怎么做,我是初学者,请多多指教!! 展开
$Part_1 = "111122223333";
print $Part_1;
print "\n";
$Part_1 =~ /(\d{4})(\d{4})(\d{4})/;
$Current_Bit = $1;
print $Current_Bit;
$Current_Bit = $2;
print $Current_Bit;
$Current_Bit = $3;
print $Current_Bit;
其中我想把匹配模式存到变量中进行匹配,例如:
$ref = '(\d{4})(\d{4})(\d{4})';
$Part_1 =~ /$ref/;
可是我不知道改怎么做,我是初学者,请多多指教!! 展开
1个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询