WBest Regex Tester

Write a regular expression and watch every match light up as you type, with capture groups, flags, and a replace preview. Free and 100% private.

🔒 100% private, matched in your browser, never uploaded View source on GitHub

0 matches

Matches

    Matches and their capture groups appear here.

    
            
    Every match, highlighted live

    Every match is highlighted in place as you type, numbered, and broken out into its capture groups, so you can tell which part of the pattern did what.

    Your browser's real engine

    Matching uses the same JavaScript regex engine your code will run on, so what you see here is exactly what Node and the browser will do.

    Safe for real data

    Regex debugging usually means pasting production logs. Nothing leaves your device, nothing is logged, and the page works offline.

    What is a regular expression?

    A regular expression, regex for short, is a small language for describing the shape of text. Rather than searching for one literal string, you describe a pattern: "an @ sign with word characters either side", "four digits, a dash, two digits". The engine then finds every stretch of text that fits.

    That power comes with a famous downside: regex is written densely and read rarely. A pattern that works is easy; a pattern you can still understand next month is the hard part. Testing interactively, watching matches appear and disappear as you edit a single character, is by far the fastest way to build one correctly.

    How to use this tester

    Type your pattern in the field at the top (no surrounding slashes needed; they are drawn for you), toggle the flags you want, and paste your text below. Matches highlight instantly, alternating shades so you can see where one ends and the next begins. The Matches panel lists each result with its position and capture groups, and the Replace preview shows what a find-and-replace would produce before you run it anywhere real.

    Greedy vs. lazy quantifiers

    By default quantifiers are greedy: .+ takes as much text as it can and then backs off only as far as it must. Add a ? to make one lazy: .+? takes as little as possible. This single character explains most "why does my regex match the whole line?" bugs. Try <.+> against <a><b>, then try <.+?>.

    Regex cheat sheet

    The syntax that covers the large majority of real-world patterns.
    TokenMatches
    .Any character except a newline (any character at all with the s flag)
    \d \DA digit 0-9 / anything that is not a digit
    \w \WA word character (letter, digit, underscore) / anything else
    \s \SAny whitespace (space, tab, newline) / anything else
    [abc] [^abc]Any one of a, b, c / any character except those
    [a-z]Any character in the range a to z
    ^ $Start / end of the string, or of each line with the m flag
    \bA word boundary, the edge between \w and non-\w
    * + ?The preceding item zero or more / one or more / zero or one times
    {2} {2,} {2,5}Exactly 2 / 2 or more / between 2 and 5 times
    +? *?Lazy versions, matching as few characters as possible
    (abc)Capture group, stores the match as $1
    (?:abc)Non-capturing group, groups without storing
    (?<name>abc)Named capture group, read back as $<name>
    a|bEither a or b
    (?=abc) (?!abc)Lookahead: followed by / not followed by (does not consume text)
    (?<=abc) (?<!abc)Lookbehind: preceded by / not preceded by
    \. \/ \\A literal dot, slash, or backslash. Escape any special character with \

    Common regex patterns

    Useful starting points. Click any example button in the tester above to load one. Treat these as pragmatic, not exhaustive: an email regex that satisfies the full RFC is famously unreadable and still would not tell you the address exists.

    Practical patterns for everyday validation and extraction.
    GoalPattern
    Email address[\w.+-]+@[\w-]+\.[\w.]+
    URLhttps?://[^\s"<>]+
    ISO date, named groups(?<year>\d{4})-(?<month>\d{2})-(?<day>\d{2})
    Hex color#(?:[0-9a-f]{3}|[0-9a-f]{6})\b
    IPv4 address\b(?:\d{1,3}\.){3}\d{1,3}\b
    Blank lines (with m)^\s*$
    Duplicated word\b(\w+)\s+\1\b
    Trailing whitespace[ \t]+$

    Frequently asked questions

    What is a regular expression?

    A regular expression (regex) is a compact pattern that describes a set of strings. Instead of searching for one fixed word, you describe its shape ("three digits, a dash, then four digits") and the engine finds every piece of text matching that shape. Regex powers find-and-replace in editors, input validation, log searching, and text extraction in almost every programming language.

    What do the regex flags g, i, m, s, u, and y mean?

    The g (global) flag finds every match instead of stopping at the first. i makes matching case-insensitive. m (multiline) makes ^ and $ match at the start and end of each line rather than the whole string. s (dotAll) lets the dot match newline characters too. u enables full Unicode mode, which is required for \p{...} property escapes. y (sticky) forces each match to start exactly where the previous one ended.

    What is the difference between a capture group and a non-capturing group?

    Parentheses like (\d+) create a capture group: the matched text is stored and can be reused as $1 in a replacement or read from the match result. Writing (?:\d+) instead creates a non-capturing group, which still groups the pattern for alternation or repetition but does not store the result. Use non-capturing groups when you only need the grouping, since they keep your group numbers meaningful.

    How do I use capture groups in a replacement?

    Refer to a numbered group as $1, $2, and so on, counting opening parentheses from the left. A named group written as (?<year>\d{4}) is referenced as $<year>. Use $& for the whole match and $$ for a literal dollar sign. The replace preview on this page shows the result before you apply it anywhere.

    Which regex flavor does this tester use?

    It uses your browser's own JavaScript (ECMAScript) engine, so results match exactly what Node.js and browser code will do. JavaScript syntax overlaps heavily with PCRE, Python, and Java, but a few things differ: JavaScript has no free-spacing x flag, no atomic groups, and no recursion. Lookbehind, named groups, and \p{...} property escapes are all supported in modern browsers.

    Is my regex or test text sent anywhere?

    No. Matching runs in JavaScript in your browser using your device's own regex engine. Your pattern and test string, often production log lines or real customer data, are never uploaded, logged, or tracked, and the page keeps working offline once loaded.