I need to support exact phrases (enclosed in quotes) in an otherwise space-separated list of terms. Thus splitting the respective string by the space-character is not suffic
A simple regular expression will do but leave the quotation marks. e.g.
'foo bar "lorem ipsum" baz'.match(/("[^"]*")|([^\s"]+)/g) output: ['foo', 'bar', '"lorem ipsum"', 'baz']
edit: beaten to it by shyamsundar, sorry for the double answer