I'm trying to figure out how to split a string into searchable terms. I need it to
- split on spaces and single quotes (ignoring single character, non-quoted results)
- return quoted phrases without the quotes
So if I'm applying it to: "quoted phrase" single words It would return
- quoted phrase
- single
- words
Here's what I have so far (in Javascript), but I have to have to strip the quotes out separately.
var searchArray = temp.match(/"[^"]*"|[^\s']{2,}/g);
for (index in searchArray)
searchArray[index] = searchArray[index].replace(/"/g, '');
Is there any way to do this using only one regular expression?