So as the title says, I try to split a string by whitespace but not inside double quotes or square brackets
I have tried this but it gives me error:
.match(/(?|[([^]])]|"([^"])"|(\w+))/g);
And to modify this which works with roundbrackets instead of square brackets, but without luck:
/([^)]+?[)]|[""].+?[""]|[^ ]+/g
What I want:
example dummy string:
sometext here " stuff here " [hello " otherstuff " 3] "goodbye"
the response I want:
[sometext, here, " stuff here ", [hello " otherstuff " 3], "goodbye"]
If anyone knows how to write the correct regex, I would be forever grateful
