Regex Tester

Test regular expressions online for free — matches are highlighted live as you type, with every capture and named group listed, a replace preview using $1 and $<name>, all JavaScript flags (g, i, m, s, u, y, d, v), common examples for emails, URLs, dates and colours, and ready-to-paste JavaScript, Python and PHP code.

100% private — everything runs in your browser. Conversion happens on your device; nothing is uploaded.

100% private — runs in your browser
Examples:

Test text
Matches & groups

    Uses your browser’s JavaScript regex engine (flags g, i, m, s, u, y, d and v; named groups and lookbehind supported). Python and PHP snippets are provided as a starting point — a few features differ between engines. Your text never leaves your device.

    How to test a regular expression

    1. Type your regular expression and flags.
    2. Paste the text to test against.
    3. See highlighted matches and the groups for each.
    4. Try a replacement, then copy the code for your language.

    What you can use it for

    • Debug patterns for form validation
    • Extract emails, URLs, dates and IDs from text
    • Write find-and-replace patterns for editors and scripts
    • Learn regex with instant feedback

    More free tools

    Building for the web?

    Format, minify, convert and generate code with our free, private developer tools.

    See all free tools →

    Frequently asked questions

    Which regex flavour does it use?

    Your browser's JavaScript engine — which supports named groups, lookbehind and Unicode property escapes. Python and PHP snippets are generated too; a few advanced features differ between engines.

    What do the flags mean?

    g finds all matches, i ignores case, m makes ^ and $ match at line breaks, s lets . match new lines, u enables full Unicode, y is sticky, d adds match indices, v enables Unicode sets.

    How do I use groups in the replacement?

    Use $1, $2… for numbered groups, $<name> for named groups and $& for the whole match.

    Is my text uploaded?

    No. Matching runs in your browser.

    How are matches and capture groups shown?

    Each match is highlighted in the test text, in alternating blue and yellow so neighbouring matches stand apart. Under Matches & groups, every match is listed with its position in the text, counted in characters from 0. Below it come the numbered groups ($1, $2…) and any named groups by name. If an optional numbered group didn't take part in a match, it shows as undefined.

    Why does it show an error instead of matches?

    If the pattern can't be compiled, for example because a bracket or group is left open, a warning line under the pattern shows your browser's error message. The highlights, match list and replace result are cleared until the pattern is valid again. The Flags box only keeps the letters d, g, i, m, s, u, v and y; any other character you type there is removed automatically.

    Why is only the first match highlighted?

    The g flag is probably missing from the Flags box. Without g, the tool stops after the first match, so only that one is highlighted and listed. Add g to find them all. Matches of zero length, such as a pattern made only of ^, $ or a lookahead, are skipped, so they don't appear in the highlights or the count.

    Are there ready-made patterns for emails, URLs or dates?

    Six buttons above the pattern box load a ready-made pattern: Email, URL, Phone, Date (YYYY-MM-DD), Hex colour and Hashtag. Each one fills in the pattern and its flags (Email also ignores case) and leaves your test text and replacement as they are. The Date example has three groups for year, month and day, so it's a quick way to see numbered groups in the match list.

    Can I preview a find-and-replace before using it?

    Yes. Type a replacement in Replace with, and Result after replace shows the whole test text with the change applied, updating as you type. It uses the same pattern and flags as the matches above, so with g every match is replaced, and without it only the first. When a replacement is entered, the JavaScript snippet also gains a matching text.replace() line you can copy.

    Is there a limit on the number of matches?

    The tool finds and highlights up to 5,000 matches in one pass. The Matches & groups list shows the first 200 in full, and the counter next to Test text shows how many were found, adding “(first 200 listed)” when there are more. Results update on every keystroke, so with a long text and many matches, a more specific pattern keeps the list easy to read.