Regular Expression Quick Reference

Anchors

^
Start of string, or start of line in multiline mode.
$
End of string, or end of line in multiline mode.
\b
Word boundary between a word and a non word character.
\B
Position that is not a word boundary.

Quantifiers

*
Zero or more of the preceding element.
+
One or more of the preceding element.
?
Zero or one of the preceding element.
{n,m}
Between n and m repetitions, both bounds optional.
*? +? ??
Lazy variants, match as few characters as possible.

Groups

(...)
Capturing group, numbered from left to right.
(?:...)
Non capturing group.
(?<name>...)
Named capturing group.
(?=...)
Positive lookahead, zero width.
(?!...)
Negative lookahead, zero width.

Syntax notes follow the POSIX extended and PCRE conventions. Flavours differ in lookbehind and named group support.