Regex tester

Test regular expressions as you type: matches are highlighted, with capture groups, named groups and a replace preview. Includes ready-made patterns for emails, UK postcodes, UK mobile numbers and dates. Runs in your browser.

Runs in your browser. Nothing is uploaded.
//

    Quick regex cheat sheet

    PatternMatches
    \d \w \sA digit, a word character (letter, digit or _), a space
    .Any character except a new line
    [abc] [^abc] [a-z]One of a, b or c; anything except them; a lowercase letter
    * + ? {2,4}0 or more, 1 or more, optional, 2 to 4 times
    ^ $ \bStart of text (or line with m), end, a word boundary
    (…) (?<name>…) (?:…)A capture group, a named group, a group that doesn't capture
    a|ba or b
    (?=…) (?!…)Followed by, not followed by

    This tester uses JavaScript's regex engine, which is the same as in Node.js and every browser. Most simple patterns also work in Python, PHP and Java, but look-behind, named groups and flags vary slightly.

    A pattern that takes more than 1.5 seconds is stopped automatically, so a runaway expression can't freeze your browser.

    Questions

    Why doesn't my pattern match across lines?

    By default . doesn't match a new line and ^ and $ match the start and end of the whole text. Turn on s to let . match new lines, and m to make ^ and $ work on each line.

    How do I match a full stop or bracket?

    Put a backslash before it: \. matches a full stop and \( an opening bracket.

    Is my text sent anywhere?

    No. Matching happens in your browser.

    More free tools