Regex Tester
Test a regular expression against sample text and see matches highlighted as you type, with capture groups broken out for every match.
Your data never leaves your browser. This tool runs entirely on your device.
Enter a regular expression to test.
What the flags do
Flags change how the whole pattern is applied. The two most consequential are global, which finds every match rather than stopping at the first, and multiline, which changes what the anchors mean.
- g (global) — return every match, not just the first.
- i (ignore case) — match regardless of capitalisation.
- m (multiline) — ^ and $ match at each line break, not only at the string ends.
- s (dotall) — let . match newline characters, which it otherwise never does.
- u (unicode) — treat the pattern as Unicode code points, needed for \p{...} classes.
- y (sticky) — match only at the exact current position.
Capture groups
Parentheses capture the text they match so you can extract it. Numbered groups are counted by the position of their opening bracket; named groups use the (?<name>...) syntax and are far easier to read six months later.
A group that did not participate in the match is undefined rather than an empty string — a distinction that matters when the group is optional.
(?<year>\d{4})-(?<month>\d{2})Catastrophic backtracking
A pattern with nested unbounded quantifiers, such as (\w+)+$, can take exponential time on input that nearly matches. The engine tries every possible way to split the string before giving up.
This is a real denial-of-service vector when a regex is applied to user input, known as ReDoS. This tester warns when it spots the shape, and caps matches at 1,000 so the page stays responsive.
Frequently asked questions
Which regex flavour does this use?
JavaScript, since it runs in your browser. Most syntax is shared with PCRE, but lookbehind support, named group syntax and Unicode property escapes vary between languages — check your target language before copying a pattern across.
Why does my pattern only find the first match?
The global flag is not set. Without g, the engine stops at the first match. This tester always enumerates all matches so you can see them, and shows your own flags separately.
How do I match a literal dot or slash?
Escape it with a backslash: \. matches a literal full stop, and \/ a literal slash. An unescaped dot matches any character except a newline.
Why is my regex extremely slow?
Almost always catastrophic backtracking from nested quantifiers like (a+)+. Rewrite the pattern to avoid nesting unbounded repetition, or anchor it more tightly so the engine has fewer ways to fail.
Should I use a regex to validate email addresses?
For a rough sanity check, yes. For real validation, no — the RFC 5322 grammar is far more permissive than people expect, and the only reliable test that an address works is sending mail to it.
Related tools
- JSON FormatterPaste JSON to pretty-print it with consistent indentation, or minify it back down. Invalid JSON is reported with the exact line and column so you can find the problem.
- URL EncoderPercent-encode text so it can travel safely in a URL. Encode a single query value, or fix only the illegal characters in a complete address.
- Hash GeneratorGenerate MD5, SHA-1, SHA-256, SHA-384 and SHA-512 digests of any text simultaneously. Everything is computed in your browser.
- Lorem Ipsum GeneratorGenerate placeholder text by paragraph, sentence or exact word count. The output is deterministic, so the same settings give the same text every time.
- Word UnscramblerEnter your tiles and see every word they can make, best score first — including the shorter words that fit when the seven-letter play will not.