I have a need to split a string on space character (' ') but while excluding any spaces that come within 2 specific characters (say single quotes).
Here is an example string:
This-is-first-token This-is-second-token 'This is third token'
The output array should look like this:
[0] = This-is-first-token
[1] = This-is-second-token
[2] = 'This is third token'
Question: Can this be done elegantly with regular expression?



/[a-zA-Z-]+|['"][\sa-zA-Z-]+['"]/g