Dtools
RGX-05

Regex Cheatsheet

A searchable quick reference for regex syntax.

Basics

.Any character except newline
\dAny digit (0-9)
\DAny non-digit
\wWord character (letter, digit, underscore)
\WNon-word character
\sWhitespace character
\SNon-whitespace character

Anchors

^Start of string or line
$End of string or line
\bWord boundary
\BNot a word boundary

Quantifiers

*Zero or more of the previous
+One or more of the previous
?Zero or one of the previous (optional)
{n}Exactly n times
{n,}n or more times
{n,m}Between n and m times
*?Zero or more, non-greedy (as few as possible)

Groups

(...)Capture group
(?:...)Non-capturing group
(?<name>...)Named capture group
(?=...)Positive lookahead
(?!...)Negative lookahead
(?<=...)Positive lookbehind
(?<!...)Negative lookbehind

Character sets

[abc]Any one of a, b, or c
[^abc]Any character except a, b, or c
[a-z]Any character from a to z

Alternation

a|bEither a or b

Flags

gGlobal — find all matches, not just the first
iCase-insensitive matching
mMultiline — ^ and $ match line boundaries
sDotall — . also matches newlines

More in Regex Tools