I need help setting a regex that can separate some strings from some commas.
This is the regex I have so far:
(?<string>(?<=")(?:[^""\\]|\\.)*(?="))|(?<comma>\,)
The idea is to group strings defined by being enclosed in quotes and also group commas. A use case would be:
"Dog", "cat", "Dog, cat"
The wanted output:
string group (3 elements):
- Dog
- cat
- Dog, cat
comma group (2 elements):
- ,
- ,
The problem is that my regex pattern reads the comma as a string too, since it's surrounded by quotes, so my output is:
string group (5 elements):
- Dog
- ,
- cat
- ,
- Dog, cat
Comma group (0 elements):