Start a project

Tool 40 of 57 · Code

Regex Tester

Write a regular expression and see every match highlighted as you type, with capture groups, a replace preview and an explanation of each part.

Regex Tester at a glanceIllustration: 1, Pattern + test text; 2, processed in your browser; 3, Highlighted matches.Regex Tester1Pattern + test text3Highlighted matches2In yourbrowser
1 Pattern + test text 2 processed on your device 3 Highlighted matches

Regex Tester

Pattern

Flags: g all, i ignore case, m multiline, s dot-all, u unicode, y sticky

Matches and groups

#MatchAtGroups
Matches (JSON)

Replace

$1, $2 for groups, $& for the whole match, $ for named groups
Result

What the pattern means

    01

    What it does

    Tests JavaScript regular expressions live, with highlighted matches, groups, replace and a plain-English breakdown.

    • Live highlighting of every match
    • Numbered and named capture groups
    • Replace with $1, $& and $<name>
    • Plain-English breakdown of the pattern

    02

    Private by design

    Everything happens in your browser. Nothing you type, paste or upload is sent anywhere, and it keeps working offline once the page has loaded.

    03

    What you get

    Matches as JSON and replaced text, with a Copy and a Download button on every result.

    • Regex
    • JavaScript
    • Testing

    Why it matters

    Regular expressions power form validation, redirects, search and data clean-up, and they're notoriously hard to read. Testing against real examples is the only reliable way to know a pattern does what you mean.

    This tester uses your browser's own JavaScript engine, so what matches here matches in your site's code. Results are capped at 1,000 matches so a pattern that matches everything can't flood the page.

    How it works

    1. InputA regular expression and some text
    2. In your browserRun by the browser's own RegExp engine
    3. OutputHighlights, groups, a replace preview and a plain-English breakdown

    Where it fits in a designer's workflow

    1. Plan
    2. Design
    3. Build
    4. Test
    5. Launch
    Writing validation and search patterns during build.

    By the numbers

    Matches for each preset on its own example textEmail: 2 matches; UK postcode: 5 matches; UK phone: 2 matches; Web address: 2 matches; Hex colour: 2 matches; Date (YYYY-MM-DD): 2 matches; Extra spaces: 3 matchesEmail2 matchesUK postcode5 matchesUK phone2 matchesWeb address2 matchesHex colour2 matchesDate (YYYY-MM-DD)2 matchesExtra spaces3 matches
    Run with this tool's own code at build time. Each preset's example text includes near misses that should not match (like 12345 for a postcode), so the counts show the pattern is strict enough. Source: MDN: regular expressions.
    Show the numbers as a table
    PresetMatchesParts explained
    Email211
    UK postcode528
    UK phone214
    Web address213
    Hex colour27
    Date (YYYY-MM-DD)223
    Extra spaces32

    How to use it

    1. Type a pattern and flags, or pick an example.
    2. Paste text to test against.
    3. Read the matches and groups in the table.
    4. Try a replacement and download the result.

    FAQ

    Which regex flavour is this?

    JavaScript (ECMAScript), as used in browsers and Node.js. Most syntax is shared with PHP, Python and others, but look-behind and named groups differ slightly.

    Why does my pattern match only once?

    Add the g flag to find every match.

    Is the UK postcode pattern complete?

    It covers the standard formats, including GIR 0AA. For certainty, check against Royal Mail's address data.

    Can a pattern freeze the page?

    Some patterns with nested repeats (like (a+)+) can take very long on certain text. That's called catastrophic backtracking; if the page slows down, simplify the repeats.

    Work with me

    Want a site that gets these right?

    I build fast, accessible websites and web apps that pass these checks from day one. Tell me about your project and I'll reply personally with honest next steps.

    All developer tools · Back to leej.uk