Right now I split words by one whitespace and store in an array: var keywds = $("#searchquery").text().split(" ");
The problem is there can/might be multiple white spaces. For example :
"hello world"
How would I still have the array = [hello, world]
Use a regular expression (
\smatches spaces, tabs, new lines, etc.)or if you want to split on spaces only:
+means match one or more of the preceding symbol.Further reading:
string.split