Test a regular expression

Type a JavaScript regular expression and some test text and see every match with its position, capture groups and named groups as you type. Matching runs in a background worker with a 250 ms limit, so a pattern that backtracks catastrophically — the kind that has taken real services offline — is stopped instead of freezing the page.

Anchors and flags

Without ^ and $, a pattern matches anywhere in the text, so a validation regex that looks right can accept "abc123xyz" when you meant only digits. The m flag makes the anchors match per line; i ignores case; u enables full Unicode.

Catastrophic backtracking

Nested quantifiers such as (a+)+ or (.*)* can take exponential time on input that almost matches. If a pattern hits the time limit here, it will hit your server too — rewrite it before it reaches a user-controlled input.

Regex in API tests

Use a regex for shape — an id format, a timestamp, a token — and exact assertions for values. Matching a whole JSON body with a regex is fragile; parse it and assert on fields.

Other tools

All tools · Getting started guide · All 55 mock REST APIs

Last updated