Regex Tester

Write a regular expression, choose flags and paste sample text. Matches are highlighted as you type, and each match shows its position and capture groups. Everything uses your browser's JavaScript regex engine.

Highlighted

Quick reference

PatternMeaning
.Any character except a newline
\d \w \sDigit, word character, whitespace (capital letters mean the opposite)
^ $Start and end of text (or line with the m flag)
* + ? {n,m}0 or more, 1 or more, optional, between n and m
(...) (?:...)Capture group, non-capturing group
(?<name>...)Named group
[abc] [^abc] [a-z]Any of, none of, a range
a|ba or b
\bWord boundary

Flags

i ignores case, m makes ^ and $ match at each line, s lets the dot match newlines, u turns on full Unicode handling. The tester always finds all matches (the g flag is added for you).

Avoiding slow patterns

Nested repetition such as (a+)+$ can take exponential time on some inputs ("catastrophic backtracking") and freeze a page or server. Prefer specific character classes, anchor your patterns, and test with long non-matching strings.

This tool uses JavaScript regex syntax; other languages (Python, PCRE, Java) differ in small ways such as lookbehind support and named-group syntax.

Frequently asked questions

Why does my pattern need double backslashes in code?

In a string literal "\\d" produces \d. In this tester you type the pattern directly, so a single backslash is correct.

What is a capture group?

Parentheses remember the text they matched so you can reuse it - for example to extract the user name and domain from an email.

Is my text uploaded?

No, matching runs locally.

More tools