freeCodeCamp/guide/english/javascript/tutorials/invert-regular-expression-matches-with-javascript/index.md
2019-01-17 11:41:32 -06:00

332 B

title
Invert Regular Expression Matches with JavaScript

Use/\S/gi; to match everything that isn't a space in the string.

Use/\W/gi; to match everything that isn't a-z, A-Z, 0-9, or the _ (underscore) in the string.

You can invert any match by using the uppercase version of the selector \s versus \S for example.