How hard is it to check for whitespace?
JavaScript takes yet another approach. It doesn’t have an equivalent of the
Character.isWhitespace()method, but we can use the\scharacter class in a regular expression\smight be the most obvious whitespace test, but the expectations are a bit more ambiguous when it comes to regex. Every regex runtime is different, so without looking it up, you’re going to end up with behavior you might not expect.Instead, if you want to match Unicode whitespace, you should use
\p{White_Space}in Unicode-aware mode (uorvflag).I haven’t looked through any other runtimes, but something tells me the inconsistencies won’t stop at these three.
According to the docs, Rust’s char::is_whitespace checks if the value has the
White_Spaceproperty, andregexdoes the same in Unicode mode (which is the default).Nice read 👍




