我使用Notepad ++并且需要更新文件字符串的早期部分存在各种差异的文件,并认为通配符可能对此有所帮助。根据我迄今为止所做的研究,我们不清楚将使用什么语法。
这是原始字符串的示例:
"123456","LEGAL","Group Legal Plan","","",0,0,,0,0,0,"20151112","20151019","W","","","","",""
"123456","HSA","Health Savings Account (HSA)","","",0,1050,350,0,0,0,"20151112","","A","","","","",""
"123456","LIFE","Basic Life Insurance","3 times salary","750000.00",12.12,0,0,32.31,0,0,"20151112","","A","","","","",""
"123456","LTD","Long-term disability plan - default plan ","60% of salary","150000.00",11.54,0,0,0,0,0,"20151112","","A","","","","",""
"123456","HFSA","Med-FSA (Medical Flexible Spending Account)","Medical Contribution","",0,0,,0,0,0,"20151112","20151019","W","","","","",""
"123456","SUPCHILDLIFE","Voluntary Child Life Insurance","","",0,0,,0,0,0,"20151112","20151019","W","","","","",""
"123456","SUPLIFE","Voluntary Life Insurance","2.0 times salary","500000.00",0,276,10.62,0,0,0,"20151112","","A","","","","",""
"123456","VISION","VSP Vision","Employee + Family","",13.25,54,2.08,0,0,0,"20151112","","A","","","","",""
"123456","SUPSPOUSELIFE","Voluntary Spouse/Domestic Partner Life Insurance","50000.00","50000.00",0,32.4,1.25,0,0,0,"20151112","","A","","","","",""
"123456","DENTAL","Delta Dental","Employee + Family","",66.96,225,8.65,0,0,0,"20151112","","A","","","","",""
"123456","DCFSA","Dependent Care FSA","Depcare Contribution","",0,0,,0,0,0,"20151112","20151019","W","","","","",""
"123456","MEDICAL","Anthem gHIP","Employee + Family","",719.35,2005.68,77.14,0,0,0,"20151112","","A","","","","",""
"123456","Imputed Income","","","",,,,0,,,"20151112","","C","DMPTN","DMPTN","","",""
"678901","LTD","Long-term disability plan - default plan ","60% of salary","66000.00",5.08,0,0,0,0,0,"20151112","","A","","","","",""
"678901","SUPSPOUSELIFE","Voluntary Spouse/Domestic Partner Life Insurance","","",0,0,,0,0,0,"20151112","20151026","W","","","","",""
"678901","SUPCHILDLIFE","Voluntary Child Life Insurance","","",0,0,,0,0,0,"20151112","20151026","W","","","","",""
"678901","MEDICAL","Anthem PPO","Employee + Spouse","",482.39,1983.48,76.29,0,0,0,"20151112","","A","","","","",""
"678901","DENTAL","Delta Dental","Employee + Spouse","",41.49,150,5.77,0,0,0,"20151112","","A","","","","",""
"678901","HSA","Health Savings Account (HSA)","","",0,0,,0,0,0,"20151112","20151026","W","","","","",""
"678901","LIFE","Basic Life Insurance","3 times salary","330000.00",5.33,0,0,11.63,0,0,"20151112","","A","","","","",""
"678901","SUPLIFE","Voluntary Life Insurance","4.0 times salary","440000.00",0,153.12,5.89,0,0,0,"20151112","","A","","","","",""
"678901","VISION","VSP Vision","Employee + Spouse","",7.93,36,1.38,0,0,0,"20151112","","A","","","","",""
"678901","DCFSA","Dependent Care FSA","Depcare Contribution","",0,0,,0,0,0,"20151112","20151026","W","","","","",""
"678901","LEGAL","Group Legal Plan","Employee Only","",0,206.64,7.95,0,0,0,"20151112","","A","","","","",""
"678901","HFSA","Med-FSA (Medical Flexible Spending Account)","Medical Contribution","",0,0,,0,0,0,"20151112","20151026","W","","","","",""
"678901","Imputed Income","","","",,,,0,,,"20151112","","C","DMPTN","DMPTN","","",""
以下是SUPLIFE行中应存在通配符的地方的示例:
"Wildcard","SUPLIFE","Voluntary Life Insurance","Wilcard","Wilcard",Wilcard,Wilcard,Wilcard,Wilcard,Wilcard,Wilcard,"20151112","","A","","","","",""
然后我想要将值VLIFE添加到下面指出的位置,其中包含find / replace。
"123456","SUPLIFE","Voluntary Life Insurance","2.0 times salary","500000.00",0,276,10.62,0,0,0,"20151112","","A","VLIFE","","","",""
我不确定是否可以这样做。
答案 0 :(得分:0)
如果我正确理解您的问题 - 是的,it's possible:
^("\d+","SUPLIFE",(?<content>(?:".*?(?<!\\)"|[^,]+)),(?:(?&content),){11})((?&content))
替换为:
$1"VLIFE"
我在Notepad ++中对它进行了测试,但它确实有效。
修改:我清理了链接中的正则表达式代码。随意使用版本3.直接链接仍然有效。