🔰character set
🚧 under construction
JS ⟩ value ⟩ object ⟩ regex ⟩ pattern ⟩ char set
. // any non-newline character
[^] // any character (including newline) ⭐️
[a-c] // (ranges) = [abc] = (a|b|c)
[^01] // invert a set (not 0, not 1 in this case)
\d // a digit = [0-9] = [0123456789]
\D // not a digit
\w // alphanumeric character (“word character”) = [a-zA-Z0-9_]
\W // nonalphanumeric character
\s // whitespace (space, tab, newline, ...)
\S // nonwhitespace
🈯 synonyms: "character class"
Only ^ - \ ]
need to be escaped inside a character class.
[.+] // ".", "+" have NO special meaning in brackets
As far as JavaScript’s regular expressions are concerned, a “word character” is only one of
A-Z
,a-z
,0-9
, and_
.Things like é or β, will not match
\w
(and will match\W
).
Last updated
Was this helpful?