Skip to content
Developer · Text Processing

Regex Tester

Build and debug regular expressions with real-time match highlighting, capture group details, substitution preview, and plain-English token explanations. Runs entirely in your browser — no patterns are sent to a server.

In-browser only JS · PCRE2 · Python Web Worker safe

All evaluation runs in your browser — no patterns are sent to a server.

Guide

How to Use

  1. 1
    Choose your engine

    Select JavaScript, PCRE2, or Python re from the flavour control at the top. The available flags update automatically to match the chosen engine.

  2. 2
    Enter a pattern

    Type your regex pattern in the input field between the / delimiters. The flags display updates as you toggle flag buttons. Press Copy (⧉) to copy the full /pattern/flags string.

  3. 3
    Test against text

    Enter or paste your test text in the large text area. Matches are highlighted in real time with numbered badges so you can distinguish multiple matches at a glance.

  4. 4
    Inspect match details

    Click any match in the details accordion below the text area to see its exact position (start–end offset) and any capture group values, including named groups.

  5. 5
    Preview substitutions

    Switch to the Substitution tab, enter a replacement string, and see the full substituted text instantly. Use back-reference syntax ($1, \1, or \g<name>) appropriate for your chosen engine.

  6. 6
    Understand your pattern

    Open the Explanation tab for a token-by-token breakdown of what each part of your pattern does. Use the Quick Reference cheatsheet on the Match tab for a searchable token reference.

How to Use

  • Choose an engine: JavaScript, PCRE2, or Python re.
  • Enter a pattern in the / … / field.
  • Type or paste test text to see matches highlighted live.
  • Expand a match to view capture group details.
  • Use the Substitution tab to preview replacements.

Reference

Engine Feature Comparison

Engine Feature Comparison
EngineNamed groupsLookbehindUnicodeVerboseBack-references
JavaScriptYesYesYesNoYes
PCRE2YesYesYesYesYes
Python reYesYesYesYesYes

Frequently Asked Questions

What is a regular expression?
A regular expression (regex) is a sequence of characters that defines a search pattern. Regex can match, extract, and replace text in a flexible and powerful way. Common uses include form validation, log parsing, and search-and-replace operations in code.
What is the difference between JavaScript, PCRE2, and Python re?
JavaScript regex is built into the browser and follows the ECMAScript standard. PCRE2 (Perl-Compatible Regular Expressions, version 2) is the engine used in PHP, Apache, and many other tools — it supports more features like possessive quantifiers and atomic groups. Python re is the standard library engine in Python, which uses a slightly different syntax for named groups ((?P<name>…)) and back-references ((?P=name)).
What does the g flag do?
The global flag (g) makes the engine find all matches in the input text rather than stopping after the first match. Without g, only the first match is returned. Most other use-cases — validation, extraction — benefit from the g flag.
What is a capture group?
A capture group is a portion of a regex wrapped in parentheses (…). The text matched by the group is stored separately so you can reference it in the match results or in a replacement string using back-references ($1, \1, etc.).
What is a named capture group?
A named capture group assigns a name to a capture group, making your pattern more readable. In JavaScript and PCRE2 the syntax is (?<name>…); in Python it is (?P<name>…). You can then reference the group by name in replacements ($<name> or \g<name>) instead of by index.
What is a ReDoS attack, and how is it prevented here?
ReDoS (Regular Expression Denial of Service) exploits catastrophically backtracking regex patterns to consume excessive CPU time. This tool runs all evaluation inside a Web Worker with a 2-second automatic timeout, so a runaway pattern will time out rather than freezing your browser tab.
What is substitution in regex?
Regex substitution replaces matches in the input text with a replacement string. The replacement string can reference captured groups using back-references — for example, $1 or \1 for the first group, $<name> or \g<name> for named groups.
Can I share a regex with someone?
Yes. Click the Share button to generate a shareable link that encodes your current pattern, flags, test text, and engine choice into the URL fragment. The link is fully client-side — no data is sent to a server. Long patterns (over 50 characters) show a confirmation prompt before running.