Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

EDIT

Proof that it should work: http://regexr.com?30pf2


I'm trying to replace all occurrences of , that are not within quotes with a ~

20,72275,Epidurography,1
21,72285,X-Ray C/T Spine Disk,1
22,72291,"Perc Vert/Sacroplasty, Fluor",1
23,72292,"Perc Vert/Sacroplasty, Ct",1

Becomes

20~72275~Epidurography~1
21~72285~X-Ray C/T Spine Disk~1
22~72291~"Perc Vert/Sacroplasty, Fluor"~1
23~72292~"Perc Vert/Sacroplasty, Ct"~1

My Regex works like a charm but I can't seem to replace the values it finds. Notepad++ highlights the comma to be replaced but passes over without making any changes when I click the Replace button.

Find what: (,)(?=(?:[^"]|"[^"]*")*$)

Replace with: ~

I've tried other values thinking ~ was somehow reserved, but every other character or combinations of characters don't seem to work either. Hopefully this is just the result of some oversight on my part. Any help would be appreciated.

I'm using Notepad++ v6.1.1

Thanks! NotePad++ ScreenShot

Regex from http://stackoverflow.com/questions/632475/regex-to-pick-commas-outside-of-quotes

share|improve this question
    
I'm not sure about v6.1.1, but v.5.9.3 doesn't support the lookarounds your regular expression uses. –  Dennis Apr 26 '12 at 18:09
1  
@Dennis - as of v6 "PCRE (Perl Compatible Regular Expressions) is supported" which supports Alternation/Lookarounds –  Brandon Boone Apr 26 '12 at 18:19
    
I just updated, and your regular expression works, but only when clicking Replace All. This sounds like a bug. –  Dennis Apr 26 '12 at 18:22
    
For me it never completes when I use Replace All. It hangs until I have to kill it. Stepping through one at a time with Replace shows that it returns to the top of the file after it reaches the bottom, but since it never replaced anything it gets stuck in an infinite loop. I think you're right about it being a bug, but I wanted to be sure. –  Brandon Boone Apr 26 '12 at 18:31
    
I have 9655 lines so I probably just wasn't patient enough. I'll try again and wait it out. Thanks for your help! –  Brandon Boone Apr 26 '12 at 18:37

2 Answers 2

up vote 3 down vote accepted

This is due to a bug in Notepad++'s RegEx engine (bug report).

When using zero-width lookaround assertions, clicking Replace simply has no effect!

For example, replacing T(?=E) with B exhibits the same behavior when used on the string TEST.

Clicking Replace All serves as a workaround until this is fixed.

share|improve this answer

Currently pipe | symbol won't support in notepad++.

The latest version Notepad 10.1.1 supports | in RegEx

share|improve this answer
    
look at line 23 for the reason someone downvoted you. –  Rob Apr 26 '12 at 18:41
    
@Rob: I have updated my answer, after it is been downvoted. Now it is latest answer –  Siva Charan Apr 26 '12 at 18:42
    
@SivaCharan - See my above comment to Dennis concerning the same statement. –  Brandon Boone Apr 26 '12 at 18:44

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.