I have the following regex:
const splitRegex = new RegExp('(".*?"|[^",]+)(?=\\s*,|\\s*$)', 'g');
const row = line.match(splitRegex);
to extract strings in quotes in this but ignoring commas, however, it doesn't work with string like: 6000.1, Basic "Internet" abc, 101, NO_VLAN
which will return just ["6000.1", "abc", "101", "NO_VLAN"
]
I tried adding regex for "a word followed by a space" ([^\s]*)(?=\s*)
at the beginning and the end of the original one but it looks even worse... [ "6000.1,", "\"Internet\" abc,", " 101,", " NO_VLAN" ]
What I would like is ["6000.1", "Basic \"Internet\" abc", "101", "NO_VLAN"
] or ["6000.1", "Basic \"Internet\"", "101", "NO_VLAN"
] if the string is 6000.1, Basic "Internet", 101, NO_VLAN
Thank you.