I have a CSV line, that looks like:
foo, bar, baz, "england, scotland, wales, ireland", sith
and need to convert it into
"foo", "bar", "baz", "england, scotland, wales, ireland", "sith"
I've decided to replace all commas between double quotes with 'comma', but after picking up a substirng between the double quotes I have a problem with regex to do so, because while using a
replace(/(.+)(,)(.+)/g, "'comma'")
I take next substring
"england, scotland, wales'comma' ireland"
instead of
"england'comma' scotland'comma' wales'comma' ireland"
I don't want to use regex with more complicated structure like
/(.+)(,)(.+)(,)(.+)(,)(.+)/g
and wish to group word with comma sign but can't pick a right regex for it, so I use a recursive substring search with match in for loop. Am I doing right, or there is a regex that fits but I haven't find it yet. Thank you.