I have a CSV I’m trying to format, but the input data has lots of commas to begin with. It would be much easier if I could simply replace all commas on a given line (AFTER the 4th) with a semicolon.
Is there anyway to do this using a simple find/replace regex, or is programming required?
The easiest way (since Notepad++’s regexes don’t support variable-length lookbehind assertions) to tackle this is probably to do it in three steps:
First, change the first four commas into something unique: Search for
and replace with
\1#COMMA#\2#COMMA#\3#COMMA#\4#COMMA#.Then, replace all commas with semicolons.
Lastly, replace all
#COMMA#s with commas.This assumes that all lines with commas do have at least four of them.