No, not really. When you use a character as a separator in
split, then you’re saying you want everything before and after that character to be in a new string, but not the character itself. Having a before and an after isn’t optional, though, so when you see an empty string it’s just because there was nothing to put into it. Consider this:
"hello".split("h"); // [ "", "ello"]
The character “h” is the separator, so we need a string before and after that point. There’s nothing that occurs before “h”, so the string doesn’t get filled. Everything after it gets put into the after string. You can see the same logic at work in
"hello".split("o"); // ["hell", ""]
In both cases, the before and after strings are created, but what is left in the original string to fill them with differs. When you split along all non-whitespace characters (
\S), you’re turning every character in the string into a separator. In this case, the algorithm is a bit more complicated because the after string of one character can be the before string of the next character. Still, the logic is the same.