2015-11-24 62 views
0

我正在使用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到下面提到的位置,因爲它包含查找/替換。

"123456","SUPLIFE","Voluntary Life Insurance","2.0 times salary","500000.00",0,276,10.62,0,0,0,"20151112","","A","VLIFE","","","","" 

我不確定這是否可以完成。

+1

這並不完全清楚你要求什麼。你想添加VLIFE到每一行,或者這個值是以某種方式從行中的其他信息計算出來的嗎? –

+0

嗨瑞安 - 我期望能夠做一個查找/替換,其中字符串的早期部分的值可能因不同的值而有所不同,並將VLIFE置於距離最後的第5個位置。換句話說,我將通過文件搜索包含SUPLIFE的字符串,以便僅查看該產品,並且我想將產品代碼添加到上面標識的適當位置;而不管在字符串之前有不同的僱員成本信息,以至於無法完全匹配。 – Specialt

回答

0

如果我理解你的問題,正確的 - 是的,it's possible

^("\d+","SUPLIFE",(?<content>(?:".*?(?<!\\)"|[^,]+)),(?:(?&content),){11})((?&content))

替換:

$1"VLIFE"

我在記事本++測試,它的工作原理。

編輯:我清理了鏈接中的正則表達式代碼。隨意使用版本3.雖然直接鏈接仍然有效。