Live Regex

Test preg_match, preg_match_all, preg_replace, preg_split, preg_grep.

/
/
Presets:
Highlighted subject (3 matches) • 0.00 ms
Contact: hi@example.com, sales@toolkit.dev
Also bob@nx.lc here.
#Full matchGroup 1Group 2
0hi@example.comhiexample.com
1sales@toolkit.devsalestoolkit.dev
2bob@nx.lcbobnx.lc
Regex cheat sheet
\d \Ddigit / non-digit
\w \Wword / non-word
\s \Swhitespace / non
. any char (except \n)
^ $start / end of string
\b \Bword boundary / not
a* a+ a?0+, 1+, 0 or 1
a{n} a{n,m}exact / range
[abc] [^abc]char class / negated
(abc)capture group
(?:abc)non-capture group
(?<name>abc)named group
a|balternation
(?=abc) (?!abc)lookahead / negative
(?<=abc) (?<!abc)lookbehind / negative
\n \r \tnewline / return / tab
\\ \/ \.escaped special chars
[a-z] [A-Z] [0-9]ranges
$1 $2backreference in replace
(?i) (?m)inline flag (PHP)
\1 \2backreference in pattern
\k<name>named backreference
[[:alpha:]]POSIX letters (PHP)
[[:digit:]]POSIX digits
[[:alnum:]]POSIX letters or digits
[[:space:]]POSIX whitespace
[[:upper:]] [[:lower:]]POSIX case
[[:punct:]]POSIX punctuation
[[:xdigit:]]POSIX hex digit
\A \zstart / end of input
\Zend of input or before final \n
\Gmatch at last position
\p{L} \p{N}unicode letter / number
\p{Lu} \p{Ll}unicode upper / lower
\p{P} \p{S}unicode punctuation / symbol
\p{Sc}currency symbol
\p{Greek}unicode script
\Xextended grapheme cluster
\h \Hhorizontal ws / not
\v \Vvertical ws / not
\Rany newline sequence
\Kreset match start
a*? a+? a??lazy quantifiers
a*+ a++ a?+possessive (PHP)
(?>abc)atomic group
(?(1)yes|no)conditional group
(?#comment)inline comment
(?J)allow duplicate names
\Q ... \Eliteral quote block
[\x00-\x7F]hex character
\xFF \x{1F600}hex / unicode codepoint
\cXcontrol character
\0 or \00null byte
e modifier (PHP<7)eval replacement, removed
icase insensitive
mmultiline ^ and $ per line
sdotall, . matches newline
uunicode (UTF-8)
xextended, ignore whitespace
Uungreedy default

Runs locally with JS RegExp. Modifiers i, m, s, u map directly; x and U are PHP-only and ignored. Lookbehind needs a modern browser.

All Developer Tools