回复 5# zhengwei007
此类问题,俺一般会使用第3方工具gawk(http://bcn.bathome.net/tool/4.1.0/gawk.exe)来处理:
对于1楼的样本:- gawk -v"FS=\042"-v"OFS=\t" "BEGIN{FS=\"\042\";OFS=\"\t\";print\"npcid\tchance\tskill\tmaxlevel\"}/<item npcId=/,/<\/item>/{if(/<item npcId=/)A=$2;if(/<detail chance=/)print A,$2,$4,$6}" L1.txt>Out1.txt
复制代码 对于2楼的样本:- gawk -v"FS=\042"-v"OFS=\t" "BEGIN{FS=\"\042\";OFS=\"\t\";print\"npcid\tchance\tabsorbType\tlevel\"}/<item npcId=/,/<\/item>/{if(/<item npcId=/)A=$2;if(/<detail chance=/){split($6,a,/, /);for(i=1;i in a;i++)print A,$2,$4,a[i]}}" L2.txt>Out2.txt
复制代码 对于5楼的样本:- gawk -v"FS=\042"-v"OFS=\t" "BEGIN{FS=\"\042\";OFS=\"\t\";A=\"\"}/<item>/,/<\/item>/{if(/<[^<]+\/>/){A?A=A\"\t\"$4:A=$4};if(/<\/item>/){print A;A=\"\"}}" L5.txt>Out5.1.txt
复制代码
|