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.
Also bob@nx.lc here.
| # | Full match | Group 1 | Group 2 |
|---|---|---|---|
| 0 | hi@example.com | hi | example.com |
| 1 | sales@toolkit.dev | sales | toolkit.dev |
| 2 | bob@nx.lc | bob | nx.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 / nota* a+ a?0+, 1+, 0 or 1a{n} a{n,m}exact / range[abc] [^abc]char class / negated(abc)capture group(?:abc)non-capture group(?<name>abc)named groupa|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 starta*? a+? a??lazy quantifiersa*+ 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 bytee modifier (PHP<7)eval replacement, removedicase insensitivemmultiline ^ and $ per linesdotall, . matches newlineuunicode (UTF-8)xextended, ignore whitespaceUungreedy defaultRuns locally with JS RegExp. Modifiers i, m, s, u map directly; x and U are PHP-only and ignored. Lookbehind needs a modern browser.