Regex Tester

Test regular expressions with live match highlighting, groups, flags and replacements.

Highlighted matches

Quick patterns

Cheat sheet

.any character\d \w \sdigit, word char, space
^ $start, end of line\bword boundary
* + ?0+, 1+, 0 or 1{n,m}between n and m
[abc] [^abc]set, negated set(a|b)group, alternation
(?:x)non-capturing group(?<n>x)named group
(?=x) (?!x)lookahead(?<=x)lookbehind

This tester uses your browser's JavaScript regex engine, so syntax matches JavaScript (ECMAScript). Python and PHP are very similar for common patterns but differ for some features such as named group syntax and lookbehind. Nothing you type is sent to our servers.

Regex tester with live highlighting

Type a regular expression and a test string and see every match highlighted instantly, with match positions and capture groups listed. Toggle flags, try a replacement with $1-style references and load common patterns for emails, URLs, UK postcodes and phone numbers.

How to test a regex

Write the pattern without slashes, choose flags, then paste sample text. Include both text that should match and text that should not, so you catch patterns that are too loose. The tool stops runaway patterns after a short time so a catastrophic-backtracking mistake will not freeze your browser.

JavaScript regex flavour

The tester uses your browser's JavaScript engine. Most basic syntax is shared with Python, PHP (PCRE), Java and others, but check differences for named groups, lookbehind support and flags before copying a pattern into another language.

Common mistakes

Forgetting to escape dots and slashes, using greedy .* where a lazy .*? is needed, anchoring with ^ and $ without the multiline flag, and validating emails with an over-strict pattern. Test edge cases.

Need a pattern written for you?

Use the AI Regex Generator to describe what you want in plain English, then test the result here.

Usein kysytyt kysymykset

Which regex flavour does this use?

JavaScript (ECMAScript), via your browser.

Does it send my text anywhere?

No. Everything runs in your browser.

What do the flags mean?

g finds all matches, i ignores case, m makes ^ and $ match per line, s lets the dot match newlines, u enables Unicode.

Why does it say the pattern is too slow?

Some patterns with nested quantifiers backtrack exponentially. Simplify them.

Can I test replacements?

Yes, enter a replacement string using $1 for groups and $& for the whole match.

Lisää kategoriassa Converters & Utilities