View Single Post
Old 02-02-2013, 02:34 PM   PM User | #5
Airblader
Regular Coder

 
Join Date: Jan 2013
Location: Germany
Posts: 357
Thanks: 3
Thanked 43 Times in 43 Posts
Airblader can only hope to improve
@ 007julien

Actually even better would be

Code:
var string = " test1 test2 test3   test4 test5    test6    test7  ";
var arr = string.replace(/(^\s+|\s+$)/g,"").split(/\s+/g);
so it can also deal with multiple spaces at the beginning or end of the string.

However, as a general rule, when questions like this one come up I like to ask what it's for because this kind of thing might be an indication for bad design.
Airblader is offline   Reply With Quote