I need to match a string like [one, two, three, hello, foobar] and extract one, two, three, hello and foobar respectively.
How can this be achieved using Regular Expressions and Javascript?
I have tried \[((\w+)\s*,?\s*)*\] but this would also match [one two, three] (, missing) and I also do not know how to extract the (\w+) group for each match.
Maybe something like this?
Working example: http://jsbin.com/edijef
Of course, this gets more complicated if you have escaped commas in your text, since splitting is no longer an option.