Q:

Replace first 3 occurrences of a character in each line

I have a tab-delimited file of genetic variants with an INFO column of many semicolon-delimited tags:
Chr Start   End Ref Alt ExAC_ALL    ExAC_AFR    ExAC_AMR    ExAC_EAS    ExAC_FIN    ExAC_NFE    ExAC_OTH    ExAC_SAS    Otherinfo   QUAL    DP  Chr Start       Ref Alt QUAL    FILTER  INFO
1   15847952    15847952    G   C   .    .    .    .    .    .    .    .    .    241.9   76196   1   15847952    .    G   C   241.9   PASS    AC=2;AF=0;AN=18332;BaseQRankSum=0.731;ClippingRankSum=-0.731;DP=76196;ExcessHet=3.1;FS=0;InbreedingCoeff=-0.0456;MLEAC=2;MLEAF=0;MQ=38.93;MQRankSum=0.515;NEGATIVE_TRAIN_SITE;QD=10.52;ReadPosRankSum=0.89;SOR=0.481;VQSLOD=-1.406        culprit=MQ
1   15847963    15847963    A   C   .    .    .    .    .    .    .    .    .    1607.1  126156  1   15847963    .    A   C   1607.1  PASS    AC=2;AF=0;AN=22004;BaseQRankSum=0.851;ClippingRankSum=-0.419;DP=126156;ExcessHet=3.4904;FS=0;InbreedingCoeff=0.0299;MLEAC=2;MLEAF=0;MQ=59.29;MQRankSum=0.18;QD=1.55;ReadPosRankSum=0.067;SOR=0.651;VQSLOD=0.995        culprit=QD
1   15847964    15847966    GCC -   .    .    .    .    .    .    .    .    .    1607.1  126156  1   15847963    .    AGCC    A   1607.1  PASS    AC=63;AF=0.003;AN=22004;BaseQRankSum=0.851;ClippingRankSum=-0.419;DP=126156;ExcessHet=3.4904;FS=0;InbreedingCoeff=0.0299;MLEAC=55;MLEAF=0.002;MQ=59.29;MQRankSum=0.18;QD=1.55;ReadPosRankSum=0.067;SOR=0.651;VQSLOD=0.995        culprit=QD
1   15847978    15847978    C   T   .    .    .    .    .    .    .    .    .    648.41  234344  1   15847978    .    C   T   648.41  PASS    AC=9;AF=0;AN=25894;BaseQRankSum=-0.572;ClippingRankSum=-0.404;DP=234344;ExcessHet=3.348;FS=2.639;InbreedingCoeff=-0.0098;MLEAC=6;MLEAF=0;MQ=58.71;MQRankSum=-0.456;NEGATIVE_TRAIN_SITE;QD=4.13;ReadPosRankSum=-0.456;SOR=0.452;VQSLOD=-1.238        culprit=QD

I want to split the first 3 semicolon-delimited terms in the INFO column:
AC=2;AF=0;AN=18332

So that they become:
AC=2    AF=0    AN=18332    BaseQRankSum=0.731;ClippingRankSum=-0.731;DP=76196;ExcessHet=3.1;FS=0;InbreedingCoeff=-0.0456;MLEAC=2;MLEAF=0;MQ=38.93;MQRankSum=0.515;NEGATIVE_TRAIN_SITE;QD=10.52;ReadPosRankSum=0.89;SOR=0.481;VQSLOD=-1.406        culprit=M

So far I've tried the following expression with sed:
sed -i .bk 's/\(A.=.*\);/\1        /g' allChr_ExAC38.hg38_multianno.txt

But this yields no changes. 
Ideally I was looking for a way to tell sed to replace the first 3 occurences of a semicolon ; for a tab, but 's/;/      /g3' doesn't seem to mean that. 

A:

Use Perl instead of sed:
perl -i.bk -pe '$c = 0; s/;/\t/ while $c++ < 3' -- file.txt

