I need a regular expression that matches all space characters that are not within double quotes. I'm working on strings like this:
apple orange "g r a p e" pear "blue berry" pineapple
I need to split this string into individual items delimited by space characters, but only the space characters not enclosed in double quotes (stars for correct matches):
apple*orange*"g r a p e"*pear*"blue berry"*pineapple
How could I do this with a regular expression? From the little bit of digging I've done it seems like operations like this might not be regex's strength, so would it be better to split the string some other way? I'm using JavaScript.