I want to split a line of text by whitespaces (i.e. get rid of all whitespaces and leave the rest as separate elements). I have this code:
line.split(/\s+/);
but it doesn't work exactly how I want. For example hi there!
it splits to: [hi,there!,] (notice 1 empty element at the end of the array). How to split a line without that last empty element?