Reference

Regular expressions reference

Tokens and patterns you reach for during validation and log searches.

Basics

.
Any character except newline (flavor-dependent).
\d \w \s
Digit, word char, whitespace.
^ $
Start / end of string (or line with /m).
*
Zero or more of the previous atom.
+
One or more.
?
Optional (zero or one).

Groups and classes

[abc]
One of a, b, or c.
[^0-9]
Not a digit.
(…)
Capturing group.
(?:…)
Non-capturing group.
a|b
Alternation.

Useful patterns

^[^@\s]+@[^@\s]+\.[^@\s]+$
Loose email shape (not RFC-perfect).
https?://\S+
HTTP(S) URL-ish token in text.
\b\d{1,3}(?:\.\d{1,3}){3}\b
IPv4-looking address.

← All reference pages · Courses