Search tools

Regex Tester

Write a regular expression, see every match highlighted as you type, and get a token-by-token explanation.

Regex Tester tool

Flags
Matches highlighted
 
Match details
#MatchPositionGroups
Replace
 
Explanation

    Processing runs in your browser.

    Regular expressions are powerful and famously hard to read. A live tester shortens the write-test-fix loop: change a character, see immediately what it matches, and understand why. The explanation panel turns cryptic tokens like \b(?<year>\d{4}) into plain language.

    Uses

    • Validation: build patterns for emails, dates, postcodes and IDs.
    • Search and replace: reformat data in an editor or script.
    • Log analysis: extract fields like IPs, timestamps or error codes.
    • Learning: experiment with the examples and read the explanations.

    How to use the Regex Tester

    1. Type your pattern between the slashes, or pick one from Examples.
    2. Tick the flags you need: g for all matches, i to ignore case, m for line-by-line ^ and $.
    3. Paste test text. Matches are highlighted and listed with their positions and capture groups.
    4. Open Replace to preview a replacement using $1 or $<name>.

    Features

    • JavaScript (ECMAScript) regex flavour — the same engine your browser and Node.js use.
    • Highlighting, match positions and numbered or named capture groups.
    • Plain-English explanation of each part of the pattern.
    • Replacement preview with $1, $<name> and $& support.
    • Protection against runaway patterns: stops after 300 ms or 2,000 matches.

    Frequently asked questions

    Why do I only get one match?

    Without the g (global) flag, JavaScript stops after the first match. Tick g to find them all.

    What are named capture groups?

    Groups written as (?<name>…). They work like numbered groups but are easier to read and reuse: in a replacement, $<year> inserts the year group.

    Will a pattern that works here work in Python or PHP?

    Usually, but not always. Basic syntax is shared, while lookbehind, named group syntax, Unicode classes and flags differ between languages. This tester follows JavaScript rules.

    What is catastrophic backtracking?

    Patterns with nested repetition, like (a+)+$, can take exponentially long on some inputs and freeze a program. The tester stops long-running searches and tells you, which is a hint to rewrite the pattern.

    Written by