I'm using the regex in the accepted answer here (Split a string by commas but ignore commas within double-quotes using Javascript) to split my CSV file, which works great except that the results of
.split(/(".*?"|[^",\s]+)(?=\s*,|\s*$)/g)
are returning the comma delimiters. I'm still new to writing my own RegEx and cannot seem to get the commas out of the result. I've tried numerous ways of creating a non-capturing group, but with no luck, for example:
.split(/((?:(".*?")|(?:[^",\s])+))(?=\s*,|\s*$)/)
For what it's worth, it is creating problems when I go to make a key:value pair object out of the data because I end up with numerous pairs like ",:,".
Here's a sample of one of the CSV records (there are many more fields, but this captures the gist and the challenge with both commas and double quotes in some of the descriptive fields):
-1821151,03/18/2021,23,018978783,"VENDOR 1",XXX11118465,999993348157,"OBJECT,OBJ TYPE,20"BLACK",,1546.0,EA