Test regular expressions in three real engines
Regular expressions look the same everywhere, but every engine has its own dialect. A pattern that works in your
browser's console may fail in a Python script or in an nginx rule. This tester runs your pattern in the engine you will
actually use: JavaScript (the native RegExp of your browser), Python
(re syntax and error messages) and PCRE2, the library behind PHP's preg_*
functions, nginx, Apache and grep -P. Matches are highlighted as you type, every capture group is listed with
its position, and you can preview substitutions.
Key differences between flavours
- Named groups: Python's
rerequires(?P<name>…); JavaScript uses(?<name>…), and PCRE accepts both forms. - Replacements: JavaScript writes
$1and$<name>, Python\1and\g<name>, PCRE$1and${name}. - Verbose mode (
x), which ignores whitespace and allows comments, exists in Python and PCRE but not in JavaScript. - Possessive quantifiers and atomic groups (
a++,(?>…)) are supported by PCRE and by Python 3.11+, not by JavaScript.
Protected against catastrophic backtracking
Patterns with nested quantifiers such as (a+)+$ or (a|aa)+$ can take exponential time on certain
inputs, a weakness known as ReDoS. This tool stops any evaluation that runs longer than one second – the JavaScript engine
runs in a Web Worker that is terminated, the Python engine has a hard timeout and PCRE2 enforces its backtracking limit – and
tells you that the pattern is dangerous. If it happens here, it can happen to your production server too.
Practical examples
^\d{4}-\d{2}-\d{2}$– an ISO date such as 2026-11-11.(?<user>[\w.+-]+)@(?<domain>[\w-]+\.[\w.]+)– split an e-mail address into user and domain.\b(?:\d{1,3}\.){3}\d{1,3}\b– find IPv4-looking addresses in a log.
JavaScript patterns never leave your browser. Python and PCRE patterns are evaluated on our server and discarded
immediately; your last pattern and text are only remembered in your browser's localStorage.