12 items
.Any character except newline
e.g. a.c → "abc", "a1c"\wWord character [a-zA-Z0-9_]
e.g. \w+ → "hello", "foo_bar"\WNon-word character
e.g. \W → " ", "!"\dDigit [0-9]
e.g. \d+ → "123"\DNon-digit
e.g. \D+ → "abc"\sWhitespace (space, tab, newline)
e.g. \s+ → " ", "\t"\SNon-whitespace
e.g. \S+ → "hello"[abc]Character set — matches a, b, or c
e.g. [aeiou] → "a"[^abc]Negated set — not a, b, or c
e.g. [^aeiou] → "b"[a-z]Range — any lowercase letter
e.g. [a-z]+ → "hello"[A-Z]Range — any uppercase letter
e.g. [A-Z]+ → "HELLO"[0-9]Range — any digit
e.g. [0-9]+ → "123"6 items
^Start of string (or line with m flag)
e.g. ^Hello → "Hello world"$End of string (or line with m flag)
e.g. world$ → "Hello world"\bWord boundary
e.g. \bword\b → "a word here"\BNon-word boundary
e.g. \Bord → "word"\AStart of string (no multiline)
e.g. \AHello\ZEnd of string
e.g. world\Z6 items
\.Escaped dot (literal .)
e.g. 3\.14 → "3.14"\*Escaped asterisk
e.g. 1\+1 → "1+1"\nNewline
e.g. line1\nline2\tTab
e.g. col1\tcol2\rCarriage return
e.g. \r\n\0Null character
e.g. abc\08 items
(abc)Capture group
e.g. (foo)+ → "foofoo"(?:abc)Non-capturing group
e.g. (?:foo)+ → "foofoo"(?<name>abc)Named capture group
e.g. (?<year>\d{4})(?=abc)Positive lookahead
e.g. \w+(?=\s) → "hello world"(?!abc)Negative lookahead
e.g. \d+(?!px) → "100em"(?<=abc)Positive lookbehind
e.g. (?<=\$)\d+(?<!abc)Negative lookbehind
e.g. (?<!\$)\d+a|bAlternation — a or b
e.g. cat|dog → "cat" or "dog"8 items
a*Zero or more of a
e.g. ab* → "a", "ab", "abbb"a+One or more of a
e.g. ab+ → "ab", "abbb"a?Zero or one of a
e.g. colou?r → "color", "colour"a{3}Exactly 3 of a
e.g. a{3} → "aaa"a{3,}3 or more of a
e.g. a{3,} → "aaa", "aaaa"a{3,6}Between 3 and 6 of a
e.g. a{3,6} → "aaa"…"aaaaaa"a*?Lazy — as few as possible
e.g. <.+?> → first tag onlya+?Lazy one or more
e.g. a+? → single "a"6 items
gGlobal — find all matches
e.g. /ab/g → all "ab"iCase-insensitive
e.g. /hello/i → "Hello", "HELLO"mMultiline — ^ and $ match line start/end
e.g. /^word/msDotall — . matches newline too
e.g. /a.b/s → "a\nb"uUnicode — treat pattern as Unicode
e.g. /\u{1F600}/uySticky — match at lastIndex only
e.g. /ab/y