Regex Syntax Reference
v1.0.0Searchable reference for regex patterns including character classes, quantifiers, anchors, groups, and lookaround.
38 entries found
Any character except newline.
a.c → 'abc', 'a_c'
Digit — equivalent to [0-9].
\d+ → '123'
Non-digit.
\D+ → 'abc'
Word character — [a-zA-Z0-9_].
\w+ → 'hello_42'
Non-word character.
\W → ' ', '!'
Whitespace — space, tab, newline.
\s+ between words
Non-whitespace.
\S+ → 'hello'
Any character in the set.
[aeiou] → 'a', 'e'
Any character NOT in the set.
[^aeiou] → consonants
Any character in the range.
[a-z]+ → 'hello'
0 or more of the preceding element.
a* → '', 'a', 'aaa'
1 or more of the preceding element.
a+ → 'a', 'aaa'
0 or 1 of the preceding element — makes it optional.
colou?r → 'color', 'colour'
Exactly n repetitions.
\d{4} → '2024'At least n repetitions.
\d{3,} → '123', '1234'Between n and m repetitions.
\d{2,4} → '12', '1234'Lazy (non-greedy) quantifiers — match as few as possible.
<.+?> matches inner tag only
Start of string (or line in multiline mode).
^Hello → 'Hello World'
End of string (or line in multiline mode).
end$ → 'the end'
Word boundary — between \w and \W.
\bcat\b → 'cat' but not 'catch'
Non-word boundary.
\Bcat → 'catch'
Start of string (Python/not JS).
End of string (Python/not JS).
Capturing group — captures the match for back-references.
(ab)+ → 'ababab'
Non-capturing group — groups without capturing.
(?:https?://)\S+
Named capturing group.
(?<year>\d{4})-(?<month>\d{2})Back-reference to capturing group 1, 2 etc.
(.)\1 → 'aa', 'bb'
Alternation — matches a or b.
cat|dog → 'cat', 'dog'
Positive lookahead — asserts abc follows.
\d+(?= dollars)
Negative lookahead — asserts abc does NOT follow.
\d+(?! dollars)
Positive lookbehind — asserts abc precedes.
(?<=\$)\d+
Negative lookbehind — asserts abc does NOT precede.
(?<!\$)\d+
Case-insensitive matching.
/hello/i → 'Hello', 'HELLO'
Global — find all matches, not just the first.
/a/g → all 'a' in string
Multiline — ^ and $ match start/end of each line.
/^hello/m
Dotall — . matches newline too.
/.+/s
Extended (verbose) — ignore whitespace, allow comments. (Python/Ruby)
/ # match digits \d+/x
Unicode mode — full Unicode matching (JS/Python).
/\p{L}+/u