Quick reference
| Pattern | Meaning |
|---|---|
. | Any character except a newline |
\d \w \s | Digit, 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|b | a or b |
\b | Word 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.