Regex \s — Match Whitespace
\s matches a single whitespace character (space, tab, newline, etc.). In JS it includes [\t\n\v\f\r ] and other Unicode whitespace. Example: /\s/ on "a b\tc" matches the space and the tab.
Open the interactive DevRef Hub tool →Key facts
| Token | \s |
|---|---|
| JS set | [\t\n\v\f\r ] + Unicode WS |
| Negation | \S |
| Example | /\s/ → " ", "\t" |
Frequently asked questions
What does \s match?
Any whitespace: space, tab, newline, and more.
What is the opposite of \s?
\S matches any non-whitespace character.
Related pages
Regex \s — Whitespace is part of DevRef Hub on GOAT Lab — a free reference you can use without signing up, and it works offline. Open the tool above for any custom value.
Part of GOAT Lab — 26 free, browser-based science, engineering and developer tools. No sign-up.