RegexEditor.dev Logo

Regex Editor & Tester

PCRE2 Regex Tester

Test PCRE2 patterns against the real PCRE2 library — compiled to WebAssembly, no server round-trip.

Free, no signup — runs entirely in your browser on RegexEditor.dev.

/
/

Test your PCRE2 regex in the editor below

PCRE2 regex: what makes it different

Full lookaround
Lookahead (?=…) (?!…) and lookbehind (?<=…) (?<!…), with alternatives of different fixed lengths allowed inside a lookbehind.
Recursion & subroutines
(?R) recurses the whole pattern; (?1) calls capture group 1 — ideal for nested structures like balanced parentheses.
Atomic & possessive
(?>…) atomic groups and a+, a*+ possessive quantifiers prune backtracking for both speed and safety.
PHP 7.3+
PHP moved from PCRE to PCRE2 in 7.3 — patterns validated here match what modern PHP will do.

PCRE2 (Perl Compatible Regular Expressions, version 10.x) is the engine behind PHP 7.3+, Apache, nginx, and countless tools. It supports the deepest feature set of any mainstream flavor: variable-length lookbehind alternatives, subroutine calls (?1), recursion (?R), atomic groups, possessive quantifiers, branch reset groups (?|…), and script runs (*script_run:…).

Because it is a backtracking engine, a poorly written PCRE2 pattern can backtrack catastrophically. Testing real match behavior before shipping is the difference between a pattern and an outage. This tester runs the actual PCRE2 library compiled to WebAssembly.

PCRE2 regex FAQ

What is the difference between PCRE and PCRE2?

PCRE2 is the 10.x series of the PCRE library — a new API and codebase, not just an upgrade. It added features such as script runs and better heap limiting. PHP 7.3+ uses PCRE2; older PHP used PCRE1.

Does PCRE2 support variable-length lookbehind?

Partially — PCRE2 allows each alternative inside a lookbehind to have its own fixed length (e.g. (?<=ab|cde)), which most other engines reject. Fully unbounded lookbehind like (?<=a*) is still not allowed. Only .NET goes further.

How do I stop catastrophic backtracking in PCRE2?

Use atomic groups (?>…) or possessive quantifiers (a*+) around repeated groups, keep quantified groups unambiguous, and set match limits (match_limit, depth_limit). Testing your pattern against long non-matching inputs — as you can here — exposes runaway backtracking.