In this fiddle, I have the following javascript statement:
document.write("one two three".split(/\S+/).length);
It prints 4 in Firefox and Chrome, also in IE9. But in IE7 it prints 2.
I’m looking for a way to split by whitespaces with consistent behavior between browsers.
Use a lowercase s, like this
This way the result will be 3, which is the answer that you want.