I have a long string, and I want to set it to an array by splitting it by the comma as long as the comma is not within square brackets or parentheses. I\'ve tried a couple o
You can use the following regex with global flag.
,(?![^\(\[]*[\]\)])
Here is a demo. It is inspired by https://stackoverflow.com/a/9030062/1630604.