Regex Tester

Test regular expressions live: highlighted matches, capture groups, replace preview and ready-made patterns

Flags
Highlighted matches

Matches

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

    Regex cheat sheet
    .
    Any character except a line break
    \d \w \s
    Digit, word character, whitespace
    \b
    Word boundary
    ^ $
    Start and end of the text (or of each line with m)
    [abc] [^abc]
    One character from the set / not in the set
    a|b
    Alternation: a or b
    ( … )
    Capture group
    (?<name> … )
    Named capture group
    (?: … )
    Non-capturing group
    * + ?
    Zero or more, one or more, optional
    {n,m}
    Between n and m repetitions
    *? +?
    Lazy quantifiers (as few as possible)
    (?= … ) (?! … )
    Lookahead: followed by / not followed by
    (?<= … ) (?<! … )
    Lookbehind: preceded by / not preceded by
    \1 \k<name>
    Backreference to a group
    \. \\ \/
    Escape a special character

    How to test a regular expression online

    1. 1

      Write or pick a pattern

      Type your regular expression in the pattern box, or choose a ready-made one such as email, URL, IPv4 address or date from the list of common patterns.

    2. 2

      Choose the flags

      Tick g to find every match, i to ignore case, m for multiline anchors, s so the dot matches line breaks, u for Unicode and y for sticky matching.

    3. 3

      Paste your test text

      Paste the text to search, or load the example text. Matches are highlighted as you type and listed with their position and groups.

    4. 4

      Preview a replacement

      Type a replacement such as $1-$2 or $<name> to see the result instantly, then copy the pattern, the matches or the replaced text.

    What you see for each match

    Every match is highlighted in the text, with alternating colors so that adjacent matches are easy to tell apart. Below, each match is listed with its number, its start and end position in the text and the matched value.

    If your pattern has capture groups, each group is shown under its match, numbered from 1 and labelled with its name when it is a named group such as (?<year>\d{4}). A group that did not take part in the match is marked as such.

    • Highlighted matches in the original text
    • Position (start and end) of every match
    • Numbered capture groups and named groups
    • Total count of matches, capped at 1000

    Flags: g, i, m, s, u and y

    Without g the tester stops at the first match, exactly like JavaScript does. With g it finds all of them. The i flag ignores upper and lower case, m makes ^ and $ match at every line, and s lets the dot match line breaks too.

    The u flag turns on full Unicode support, which is needed for emoji, \p{L} property escapes and correct handling of characters outside the basic plane. The y flag only matches starting exactly at the current position.

    Replace mode

    The replacement text supports the same placeholders as JavaScript: $1, $2 for numbered groups, $<name> for named groups, $& for the whole match and $$ for a literal dollar sign. Without the g flag only the first match is replaced.

    For example, with the pattern (?<year>\d{4})-(?<month>\d{2})-(?<day>\d{2}) the replacement $<day>/$<month>/$<year> turns 2026-10-06 into 06/10/2026.

    Errors and slow patterns

    When the expression is not valid, for example an unclosed parenthesis or a quantifier with nothing to repeat, the tester shows the exact message from your browser so you can find the problem.

    Some patterns, such as (a+)+$ against a long string of a letters, can take exponential time. The tester runs the match in the background and stops it after two seconds, so your page never freezes. Zero-length matches are handled safely, and the list is capped at 1000 matches.

    JavaScript flavor and privacy

    The tester uses the regular expression engine of your browser, so it follows the JavaScript (ECMAScript) syntax, including lookahead, lookbehind and named groups. Other languages such as PHP, Python or Java are very similar for everyday patterns, but a few features differ.

    Your pattern and text are processed in your browser and never sent to a server, so it is safe to test against logs, emails or any data you would not want to upload.

    Regex tester FAQ

    How do I test a regex online?

    Type the pattern, paste your text and the matches are highlighted instantly. Use the checkboxes to set the flags and the list below to inspect positions and groups.

    Which regex flavor does it use?

    The JavaScript (ECMAScript) flavor of your browser, with support for lookbehind, named groups and the flags g, i, m, s, u and y.

    Why do I only get one match?

    Because the g (global) flag is off. Without it, a regular expression stops at the first match. Tick g to find all matches.

    How do I use capture groups in the replacement?

    Write $1, $2 and so on for numbered groups, or $<name> for named groups. Use $& for the whole match.

    What does "The pattern took too long" mean?

    The pattern caused catastrophic backtracking, where the number of attempts explodes on some inputs. The test was stopped after two seconds to protect your browser. Make the pattern more specific, for example by avoiding nested quantifiers like (a+)+.

    Is my text uploaded anywhere?

    No. The test runs entirely in your browser, so you can safely use it with private data.

    Is it free?

    Yes. It is free, needs no sign-up and has no limit on the pattern or text size, except that at most 1000 matches are listed.