Is there a way to return the delimiters for a split only if all strings are quoted using regex?
Considering that the string should be splitted by "-".
Using ((?<=")-(?=")) it matches the 2 - and that's ok with the following sample:
"abc"-"123"-"zxc".
But the regex matches 2 - in the following samples when should not detect any -:
abc"-"123"-"zxc"
"abc"-"123"-"zxc
Using -(?=([^"]*"[^"]*")*[^"]*$) it matches the 2 - and that's ok with the following samples:
"abc"-"123"-"zxc".
It does not match any - on the following samples and that's ok too:
"abc"-"123"-"zxc
"abc"-"123"-zxc"
But the regex matches 2 - in the following samples when should not detect any -:
abc"-"123"-"zxc"
abc-"123"-"zxc"
"abc"-"123"-zxc
I was thinking to apply 2 regex, if the string matches with ^"[\da-z\-"]*"$ I would apply the split with ((?<=")-(?=")) but I feel that there is a way that I haven't tried yet.