如何用perl正则表达式取200个变量
我的文件中的每一行是这样的:
1 4836121 rs394594 A G 31.85 PASS AC=2;AF=1.00;AN=2;DB;DP=2;Dels=0.00;FS=0.000;HRun=0;HaplotypeScore=0.0000;MQ=60.00;MQ0=0;QD=15.93;SB=-0.01;VQSLOD=7.8708;culprit=HaplotypeScore;set=variant135 GT:AD:DP:GQ:PL ./. ./. ./. ./. ./. ./. ./. ./. ./. ./. ./. ./. ./. ./. ./. ./. ./. ./. ./. ./. ./. ./. ./. ./. ./. ./. ./. ./. ./. ./. ./. ./. ./. ./. ./. ./. ./. ./. 1/1:0,2:2:6:63,6,0 ./. ./. ./. ./. ./. ./. ./. ./. ./. ./. ./. ./. ./. ./. ./. ./. ./. ./. ./. ./. ./. ./. ./. ./. ./. ./. ./. ./. ./. ./. ./. ./. ./. ./. ./. ./. ./. ./. ./. ./. ./. ./. ./. ./. ./. ./. ./. ./. ./. ./. ./. ./. ./. ./. ./. ./. ./. ./. ./. ./. ./. ./. ./. ./. ./. ./. ./. ./. ./. ./. ./. ./. ./. ./. ./. ./. ./. ./. ./. ./. ./. ./. ./. ./. ./. ./. ./. ./. ./. ./. ./. ./. ./. ./. ./. ./. ./. ./. ./. ./. ./. ./. ./. ./. ./. ./. ./. ./. ./. ./. ./. ./. ./. ./. ./. ./. ./. ./. ./. ./. ./. ./. ./. ./. ./. ./. ./. ./. ./. ./. ./. ./. ./. ./. ./. ./. ./. ./. ./. ./. ./. ./. ./. ./. ./. ./. ./. ./. ./. ./. ./. ./. ./. ./. ./. ./. ./. ./. ./. ./. ./.
我想将红色部分通过正则表达式提取出来
if($vcf_row=~ m{(\w+)\t(\d+)\t(\S+)\t\w+\t\w+\t.+PASS.+\tGT:.+((\S[\/|\|]\S)+)})
但是似乎不对,尤其是红色部分个数不定的时候n个 如何提取那?怎么转换到变量$1,$2,,,,$n中去那,谢谢!
[解决办法]
不清楚这些[color=#FF0000]./.是什么意思。
对于个数不定,你可以在程序中显式写个循环来提取吧。[/color]
[解决办法]
$_ = '1 4836121 rs394594 A G 31.85 PASS AC=2;AF=1.00;AN=2;DB;DP=2;Dels=0.00;FS=0.000;HRun=0;HaplotypeScore=0.0000;MQ=60.00;MQ0=0;QD=15.93;SB=-0.01;VQSLOD=7.8708;culprit=HaplotypeScore;set=variant135 GT:AD:DP:GQ:PL ./. ./. ./. ./. ./. ./. ./. ./. ./. ./. ./. ./. ./. ./. ./. ./. ./. ./. ./. ./. ./. ./. ./. ./. ./. ./. ./. ./. ./. ./. ./. ./. ./. ./. ./. ./. ./. ./. 1/1:0,2:2:6:63,6,0 ./. ./. ./. ./. ./. ./. ./. ./. ./. ./. ./. ./. ./. ./. ./. ./. ./. ./. ./. ./. ./. ./. ./. ./. ./. ./. ./. ./. ./. ./. ./. ./. ./. ./. ./. ./. ./. ./. ./. ./. ./. ./. ./. ./. ./. ./. ./. ./. ./. ./. ./. ./. ./. ./. ./. ./. ./. ./. ./. ./. ./. ./. ./. ./. ./. ./. ./. ./. ./. ./. ./. ./. ./. ./. ./. ./. ./. ./. ./. ./. ./. ./. ./. ./. ./. ./. ./. ./. ./. ./. ./. ./. ./. ./. ./. ./. ./. ./. ./. ./. ./. ./. ./. ./. ./. ./. ./. ./. ./. ./. ./. ./. ./. ./. ./. ./. ./. ./. ./. ./. ./. ./. ./. ./. ./. ./. ./. ./. ./. ./. ./. ./. ./. ./. ./. ./. ./. ./. ./. ./. ./. ./. ./. ./. ./. ./. ./. ./. ./. ./. ./. ./. ./. ./. ./. ./. ./. ./. ./. ./. ./.';
if (/GT:AD:DP:GQ:PL(.*)$/) {
@d = $1 =~ /\s*(\S+)/g;
print join("\n", @d), "\n";
}