Test and Debug Regular Expressions
Write a pattern, toggle flags and watch every match light up in your test text. Each match is listed with its position and capture groups, and a replace preview shows exactly what String.replace would produce.
How to test a regex
- Enter the pattern without slashes; syntax errors appear under the field as you type.
- Toggle the flags you need (g, i, m, s, u, y and d where supported).
- Paste your test string — matches are highlighted and listed with index ranges and capture groups.
- Tick Replace and enter a replacement using $1, $<name> or $& to preview the result, then copy or download the matches.
Why a pattern can freeze other testers
Nested quantifiers such as (a+)+ or (\w+\s?)*$ can trigger catastrophic backtracking, where the engine tries an exponential number of paths on input that almost matches. Here matching runs in a background worker that is stopped after 1.5 seconds, so the page stays responsive and you get a clear message instead of a frozen tab. Rewrite such patterns with more specific character classes or without nested repetition.
Benefits
- Runs in a Web Worker with a time limit, so a runaway pattern can never lock up the page.
- Shows named groups by name and, with the d flag, the start and end index of every group.
- Includes a compact cheat sheet of tokens, quantifiers, groups and lookarounds.
Limitations
- Uses the JavaScript (ECMAScript) regex engine; PCRE-only features such as possessive quantifiers, atomic groups or recursion are not available.
- At most 10,000 matches are collected and only the first 2,000 are highlighted.
- Lookbehind and the d and v flags depend on your browser version.
Privacy and security
Your pattern and test text are processed in a Web Worker inside this browser tab and are never uploaded.
Read our privacy policy for details about the site as a whole.
Frequently asked questions
Why does my pattern match only once?
Without the g (global) flag JavaScript stops after the first match. Enable g to find every occurrence.
How do I match across multiple lines?
Use the m flag so ^ and $ match at each line break, and the s flag so . also matches newline characters.
Will a regex from Python or PHP work here?
Most common syntax is the same, but some features differ: Python's (?P<name>...) must be written (?<name>...), and inline modifiers like (?i) are not supported in most browsers.