Regex Tester

Reserved · Sponsored728 × 90 · zero layout shift

What this tool does

Write a pattern, drop in sample text, and watch matches highlight instantly as you type. This tester uses the browser's native RegExp engine, so what you see here is exactly how the pattern behaves in JavaScript — no server round-trip, no surprises when you paste it into your code. Toggle flags, inspect capture groups per match, and lean on the built-in token reference when you forget whether it's \d or \D.

How to use

  1. 1
    Write your pattern

    Type a regular expression into the Pattern field without the surrounding slashes — just the body, e.g. (\w+)@(\w+\.\w+).

  2. 2
    Toggle flags

    Click g, i, m, s, u, or y to enable them. Global (g) is required to highlight every match instead of just the first.

  3. 3
    Paste test text

    Drop sample text into the Test String panel. Matches highlight live in the Preview panel as you edit the pattern or the text.

  4. 4
    Inspect capture groups

    Each match lists its full text plus numbered and named capture groups below the preview, so you can confirm extraction logic before shipping it.

Use cases

  • Validate form input patterns

    Confirm an email, phone, or slug pattern matches your valid examples and rejects the malformed ones before wiring it into a form validator.

  • Extract fields from log lines

    Build a capture-group pattern against a real log sample and verify each field lands in the right group before writing a parser.

  • Debug a pattern that's misbehaving in code

    Paste the exact pattern and a failing input to see, character by character, why a match isn't happening the way you expect.

  • Learn regex syntax hands-on

    Use the quick reference panel alongside live highlighting to see immediately how each token changes what gets matched.

FAQ

Does this use the same regex engine as my JavaScript code?+

Yes. Matching runs entirely with the browser's native RegExp implementation — the same engine Node.js and every modern browser uses — so behavior here matches what you'll see at runtime.

Why isn't my pattern matching more than once?+

Without the global (g) flag, JavaScript's RegExp only reports the first match. Enable g to see every occurrence highlighted and listed.

What does the sticky (y) flag do differently from global?+

Sticky anchors matching to lastIndex — the exact position in the string — rather than scanning forward to find the next match. It's mostly useful for building tokenizers; for general testing, g is usually what you want.

How are named capture groups shown?+

If your pattern uses (?<name>...) groups, each match lists them alongside numbered groups, labeled with the name you chose so you can verify the mapping your code will rely on.

Why does my pattern show an error instead of results?+

The pattern failed to compile as a valid JavaScript RegExp — usually an unbalanced bracket, an invalid escape, or an unsupported flag combination (like u and unpaired surrogate ranges). The error message is passed through directly from the engine.

Related tools