Regex & pattern matching

regex flavor testerreal PCRE2 and RE2

Choose an implemented engine, enter a pattern body and test text, then run it locally.

regex flavor tester

Pattern

Enter a pattern body without / delimiters. RE2 always uses Unicode internally.

Test text

Result

Ready for input or a manual test.

All matching runs locally in a browser Worker; no pattern or test text is uploaded.

Options

Ready for input or a manual test.

Engine capability matrix

Only PCRE2 and RE2 run here. Language rows are references, not selectable engines.

TargetRuns hereLookbehindBackreferenceBoundary
PCRE2RunsYesYesPCRE2 WASM, without PHP wrappers.
RE2RunsNoNoRE2 WASM, not Go or Rust runtime.
PHP / PCRE2PCRE2 coreYesYesPHP preg_* adds delimiters and API behavior.
JavaReference onlyYesYesNo Java runtime is bundled.
GoReference onlyNoNoGo regexp is a separate implementation.
RustReference onlyNoNoRust regex is a separate implementation.
.NETReference onlyYesYesNo .NET runtime is bundled.

A regex flavor tester helps when a pattern moves from PHP to a Go service and a JavaScript highlight proves little about its destination. Keep one sample and inspect actual compilation.

This regex engine comparison executes PCRE2 and RE2. A PCRE2 regex tester is useful for the engine core; a Go regex tester or Rust regex tester needs those languages’ own runtimes for final verification.

Why use a regex flavor tester

See a real compilation difference without changing test data.

Actual engine builds

The regex flavor tester runs PCRE2 or RE2 instead of relabeling JavaScript. Lookbehind matches with PCRE2 and raises a syntax error with RE2.

PCRE2 highlights one match while RE2 shows a syntax failure for the same abstract pattern.

Stale exports stay blocked

Changing an engine, pattern, text or flag disables copying and downloading until the next successful run.

A report card dims and its export arrow locks after the input changes.

Compare a pattern without guessing

01

Use the pattern body

Write (?<=a)b without / delimiters. Loading an example first previews the fields it will replace and can be undone once.

  • An empty pattern runs only when you explicitly start a test.
02

Choose the executing engine

PCRE2 is selected first; RE2 uses a separate WASM build. i and m start off.

  • Ctrl/Cmd+Enter runs; edits do not trigger automatic execution.
03

Inspect the full report

Positions are zero-based UTF-16 units with an exclusive end. Screen rows grow by 50, while JSON contains every valid match.

  • A timeout or exceeded limit produces no partial export.

What each run reveals

Real syntax differences

PCRE2 accepts lookbehind and backreferences; RE2 rejects them. Errors are shown without a JavaScript fallback.

Captures and coordinates

Every match shows numbered and named groups. RE2 code-point indices are converted before highlighting text after emoji.

Bounded execution

A Worker can be stopped or terminated after two seconds. Input, match count and report limits reject incomplete work.

Engine behavior and limits

PCRE2 is not all of PHP
The PCRE2 core runs here; PHP preg_match delimiters, return structure and runtime configuration are not emulated.
RE2 is not Go or Rust
Go regexp and Rust regex have related syntax but separate implementations. Their matrix rows are references, not executed results.
Matching only
Replacement, extraction and splitting are outside this version because substitution tokens differ across engines.
No partial success
At most 100000 UTF-16 input units, 2000 pattern units, 1000 matches and 2000000 report units; two seconds ends a run.

Questions about regex flavor tester

Which regex flavor should I use for PHP?

The regex flavor tester defaults to PCRE2, the engine core behind modern PHP. It does not run the PHP preg_* wrapper.

Why does my regex work in JavaScript but not Go?

JavaScript may accept lookbehind or backreferences that RE2 rejects. Test RE2 here, then verify final behavior in Go regexp.

Does Go regex support lookbehind?

No. RE2 returns a compile error for lookbehind, which is shown without switching engines.

Can the same regular expression be reused across languages?

No guarantee. Unicode classes, flags and captures vary; run the pattern in its target language before deployment.

How do I test a pattern with the real target engine?

Only PCRE2 and RE2 execute here. Java and .NET are reference rows, and Rust needs its own regex crate.

Still have a question?

Try the regex flavor tester

Run the regex flavor tester with a difference example, then switch between PCRE2 and RE2 on the same text.

Pattern and test text stay in the browser; no automatic network request is made.