Splitting string by whitespace, without empty elements? April 18, 2023 by Tarik You could simply match all non-space character sequences: str.match(/[^ ]+/g)