I'm having trouble coming up with the regex I need to do this find/replace in Notepad++. I'm fine with needing a couple of separate searches to complete the process.
Basically I need to add a |
at the beginning and end of every line from a CSV, plus replace all the ,
with |
. Then, on any value with only 1 character, I need to put two spaces around the character on each side ("A" becomes " A ")
Source:
col1,col2,col3,col4,col5,col6
name,desc,something,else,here,too
another,,three,,,
single,characters,here,a,b,c
last,line,here,,almost,
Results:
|col1|col2|col3|col4|col5|col6|
|name|desc|something|else|here|too|
|another||three||||
|single|characters|here| a | b | c |
|last|line|here||almost||
Adding the |
to the beginning and the end of the line is simple enough, and replacing ,
with |
is obviously straightforward. But I can't come up with the regex to find |x|
where x
is limited to a single character. I'm sure it is simple, but I'm new to regex.