Skip to content

Regex tester

Test a regular expression against sample text with live match highlighting, a plain-English breakdown of the pattern, and match or replace mode.

Mode
Quick patterns
//

g global, i case-insensitive, m multiline, s dot matches newline, u unicode, y sticky.

 

Pattern breakdown

    Matches

     

    #MatchPositionGroups

    How it works

    This tool tests a regular expression against sample text using the JavaScript RegExp engine, with matches highlighted as you type, a plain-English breakdown of what the pattern means, and named or numbered capture groups shown for every match.

    1. Enter a pattern and flags

      Or start from a quick pattern and adjust it.

    2. Paste your test string

      Matches highlight live, with position and capture groups listed.

    3. Switch to Replace, if needed

      See the substituted text before you use it in code.

    Reading the pattern breakdown and match list

    The pattern breakdown reads the regular expression left to right and explains each token in plain English: a character class, an anchor, a quantifier, a group. It is a guide for understanding a pattern, not a full parser, so an unusual or malformed construct may be described generically.

    • Flags: g finds every match instead of stopping at the first; i ignores case; m makes ^ and $ match the start and end of each line; s lets a dot match a line break; u enables full Unicode mode; y anchors matching at the last index.
    • Capture groups: parentheses capture part of a match for reuse. A named group, (?<year>\d{4}), appears in the match list by name as well as by number.
    • Replace mode: $1, $2 refer to numbered groups and $<name> to a named group, the same syntax JavaScript's String.replace uses.

    JavaScript regex, not PCRE

    This tool uses the JavaScript RegExp engine, which differs from PCRE, used in PHP, Python's re module, and many others, in several ways: lookbehind support varies by engine version, named groups use the (?<name>...) syntax, and Unicode handling differs without the u flag. Always test in your target language before deploying a pattern to production. Everything here runs in your browser; your text, which may include log lines or personal data, is never sent anywhere.

    Frequently asked questions

    How do I test a regular expression against sample text online?

    Enter your pattern between the two slash delimiters, set any flags, g for global, i for case-insensitive, in the flags field, then type or paste your test string. Matches are highlighted in real time as you type, and the match list below shows each match, its index, and its character position.

    Is this regex tester safe to use with sensitive data?

    Yes. The Regex Tester runs entirely in your browser using the JavaScript RegExp engine. No data is transmitted to any server. You can safely test patterns against real log lines, personal data, or internal data without it leaving your machine.

    How do I use the regex replace mode to test substitutions?

    Switch the mode toggle from Match to Replace. A replacement field appears, where you can use $1, $2 for numbered capture groups or $<name> for a named group, and the replaced output is shown live. This is useful for validating find-and-replace operations before applying them in code or an editor.

    What are the quick-pattern presets and when should I use them?

    The preset buttons, Email, URL, IP address, Phone, Hex color, Date, load commonly needed regex patterns with appropriate flags in one click. Use them as a starting point and modify the pattern to match your specific format. They are not guaranteed to cover every edge case, for instance the email preset follows a common approximation, not the full RFC 5321 specification.

    Why does my regex work in JavaScript but not in Python or other languages?

    This tool uses the JavaScript RegExp engine, which differs from PCRE, used in PHP, Python's re module, and many others, in several ways. Lookbehind support varies by engine version, named groups use different syntax in some languages, and Unicode handling differs. Always test in the target language before deploying a pattern to production.