简体   繁体   中英

Notepad++ Wildcard code to find/replace

I'm using Notepad++ and need to update a file where there are various differences in earlier sections of the string of text and think Wildcards may help here. From the research I've done thus far, it isn't clear what syntax would be used for this.

Here's an example of the original string:

"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","","",""

Here's an example of the places in the SUPLIFE line where the wildcards are should be present:

"Wildcard","SUPLIFE","Voluntary Life Insurance","Wilcard","Wilcard",Wilcard,Wilcard,Wilcard,Wilcard,Wilcard,Wilcard,"20151112","","A","","","","",""

I would then want to add a value, VLIFE to the position noted below as containing this with a find/replace.

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

I'm not sure if this can be done or not.

If I'm understanding your problem, correctly - yes, it's possible :

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

Replace with:

$1"VLIFE"

I tested it in Notepad++ and it works.

Edit: I cleaned up the regex code in the link. Feel free to use version 3. The direct link still works, though.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM