I have an input like:
apple, orange, (pear, banana, grape), mango
that I want to split as:
apple
orange
(pear, banana, grape)
mango
I don't understand the regex fully, but I think I would use ,(?![^()]*)) which I found here - Java split string on comma(,) except when between parenthesis ()
I am using VBA, so if I have the input stored in an array, I would typically do:
array = Split(string, ",")
But this would yield the result as:
apple
orange
(pear
banana
grape)
mango
which I don't want.
I'm pretty sure I can find a way to replace ( and ) with nothing so they disappear from the output, but I don't know how to feed my regex string logic to my VBA formula.
I thought something like this would work:
array = Split(string, ",(?![^()]*\))")
But it doesn't. I did enable the "Microsoft VBScript Regular Expressions 5.5" reference but it didn't seem to help.
Any advice is appreciated.
Thank you,