Check a pattern before it touches real data.

A regular expression is a small search language: one line that can find every date, email address or doubled word in a page of text. It is also easy to get slightly wrong.

Type a pattern, paste some text, and watch the matches light up as you edit. Groups and replacements are listed too, so you know exactly what your code will see.

Runs in your browser. Nothing is uploaded.

Matches highlighted

Match details

    More developer tools · All 54 tools

    How to use it

    1. Type the pattern into Pattern without the surrounding slashes, or start from one in Common patterns.
    2. Tick the flags you need: g global, i ignore case, m multiline, s dot matches newline, u Unicode.
    3. Paste sample text into Test text. Matches are highlighted under Matches highlighted.
    4. Read Match details for the position of each match and the value of every group.
    5. To preview a find and replace, type into Replace with, using $1 and $2 for numbered groups or a named group reference, and read the Result.

    Good to know

    Which rules apply

    Patterns run with the JavaScript engine in your browser, following the ECMAScript RegExp rules. Most everyday syntax is the same in Python, PHP, Java and .NET, but lookbehind, named groups, possessive quantifiers and flag letters differ between engines, so test in your own language too.

    Quick reference

    WriteMatches
    \da digit 0–9
    \wa letter, digit or underscore (ASCII only)
    \sa space, tab or line break
    \bthe edge of a word
    [a-f]one character in the set
    x{2,4}x, two to four times
    (…) / (?<name>…)a numbered or named group
    a|ba or b

    A worked example

    Pattern (\d{4})-(\d{2})-(\d{2}) on the text Due 2026-03-14 finds one match, 2026-03-14, at index 4, with groups $1 = 2026, $2 = 03 and $3 = 14. The replacement $3/$2/$1 turns the text into Due 14/03/2026. A named group is written as Other replacement tokens: $&lt;name>. Other replacement tokens: Other replacement tokens: $&amp; is the whole match and $$ is a dollar sign.

    Flags that change results

    • Without g, only the first match is found and only the first is replaced.
    • m makes ^ and $ match at every line, not just the start and end of the text.
    • u treats an emoji as one character instead of two halves, and allows \p{L} for letters in any script.

    Slow patterns are stopped

    Nested repeats such as (a+)+$ can make the engine try billions of paths on text that almost matches. Your pattern runs in a background worker, and if it takes longer than 1.5 seconds it is stopped so the page stays usable. Up to 1,000 matches are found, and the details list shows the first 200.

    Questions.

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

    Usually, for the common parts. Engines differ on lookbehind, named group syntax, Unicode classes and flags, so run a quick test in the language you will use.

    Why does it say my pattern was stopped?

    It took more than 1.5 seconds, which almost always means catastrophic backtracking from nested repeats. Make the inner part more specific, for example [^,]+ instead of .+.

    Why does \w not match é or ü?

    In JavaScript \w only covers A–Z, a–z, 0–9 and underscore. Tick u Unicode and use \p{L} to match letters in any language.

    Why did only the first match get replaced?

    The g flag is off. Without it, JavaScript finds and replaces just the first match.

    Is my text kept anywhere?

    Your pattern, test text and replacement are saved in this browser only, so they are still there after a refresh. They are never sent anywhere.

    Can I check email addresses with a regex?

    A loose check such as something@something.something catches typing mistakes. Real address rules are far more complex, and only a confirmation email proves an address works.