I\'m working with some comma delimited text files. The file is comprised of approximately 400 rows and 94 columns all comma delimited and withing double quotes:
Use a look around
(?<!"),(?!")
replacing it with a pipe.
which means
(?<!") - character before is not a "
, - match a comma
(?!") - character after is not a "
Rather than interfere with what is evidently source data, i.e. the stuff inside the quotes, you might consider replacing the field-separator commas instead:
s/,([^,"]*|"[^"]*")(?=(,|$))/|$1/g
Note that this also handles non-quoted fields.
On this data: "H",9,"YES","NO","4,5","Y","N"
$ perl -pe 's/,([^,"]*|"[^"]*")(?=(,|$))/|$1/g' commasep
"H"|9|"YES"|"NO"|"4,5"|"Y"|"N"
Which can afterwards be split on "|":
$ perl -ne 's/,([^,"]*|"[^"]*")(?=(,|$))/|$1/g;print join "---",split "\\|"' commasep
"H"---9---"YES"---"NO"---"4,5"---"Y"---"N"