Regex Tester

Test and debug regular expressions against sample text. Matches are highlighted so you can quickly see what your regex is capturing.

Matches: 2

Test Text

Matches Highlighted

Contact us at support@example.com or admin@example.org.

Matches are underlined and highlighted in red. All processing happens in your browser.

Common Regex Patterns

Click any pattern to load it into the tester above. You can tweak it for your own use cases.

Regex Cheatsheet

Quick reference for everyday regular expressions. Syntax may vary slightly between languages, but these work well in JavaScript/TypeScript.

Basics & Anchors

.Any single character except newline
^Start of line/string
$End of line/string
\bWord boundaryExample: \bword\b
[abc]Any of a, b, or cExample: [aeiou]
[^abc]Any char except a, b, or c

Quantifiers

*0 or moreExample: a*
+1 or moreExample: a+
?0 or 1 (optional)Example: colou?r
{n}Exactly nExample: \d{4}
{n,}At least nExample: \d{2,}
{n,m}Between n and mExample: \d{2,4}

Groups & Lookarounds

(...)Capturing groupExample: (\d{4})-(\d{2})-(\d{2})
(?:...)Non-capturing groupExample: (?:Mr|Ms)\.
(?=...)Positive lookaheadExample: \d(?=px)
(?!...)Negative lookaheadExample: ^(?!.*forbidden)

Shorthands

\dDigit [0-9]
\DNon-digit
\wWord char [A-Za-z0-9_]
\WNon-word char
\sWhitespace (space, tab, newline…)
\SNon-whitespace

Flags (JS / TS)

gGlobal (find all matches)
iIgnore case
mMulti-line ^ and $
sDotall (dot matches newline)
uUnicode mode

Related tools