try see compare understand learn JavaScript Regular Expressions
Character classes

MDN - Character classes

Character classes are special notations that matches any character from a certain set. They are also called as Metacharacters. The commonly used Character classes are:

  • . (dot character) for any character except \n (a newline). Use 's' flag if you want to include it.
  • \d for digits.
  • \D for non digits.
  • \s for spaces, tabs, newlines.
  • \S for non spaces.
  • \w for alphanumeric and _ (underscore).
  • \W for all but \w.