Interactive Regex Tester & Explainer
Test a regular expression against your text, see every match live, and get a plain-English breakdown of what each part of the pattern does — with JavaScript flag toggles, all in your browser.
Interactive Client Prototype Sandbox
No patterns matches discovered.
\ba word boundary[A-Za-z0-9._%+-]+any of A to Z, a to z, 0 to 9, ".", "_", "%", "+", "-", one or more times@the literal character "@"[A-Za-z0-9.-]+any of A to Z, a to z, 0 to 9, ".", "-", one or more times\.a literal "."[A-Za-z]{2,}any of A to Z, a to z, 2 or more times\ba word boundary
Disclaimer: This free tool is provided “as is,” without warranties of any kind, and is for general informational purposes only — not professional, legal, financial, medical, tax, or engineering advice. Results may contain errors; verify anything important independently and use at your own risk. We accept no liability for any loss or damage arising from its use. See our Terms of Use for details.
Step-by-Step Guide
Type your regular expression into the pattern field and toggle the JavaScript flags you need: g (global — find all matches, not just the first), i (case-insensitive), m (multiline — ^ and $ match line boundaries, not just string boundaries), and s (dotAll — makes . match newlines). Paste or type your test text and every match is highlighted and listed live, with a running total. The pattern breakdown below the input explains each token in plain English.
Understanding the plain-English breakdown
The explainer parses your pattern token by token: character classes ([A-Z], \d, \w), quantifiers ({2,}, *, +, ?), anchors (^, $, \b), groups ((…), (?:…), (?=…)), and alternation (|). For example, the pattern ^(\w+)@([\w.-]+)\.([a-z]{2,})$ breaks down as: 'start of string, then one or more word characters (captured), then @, then one or more word/dot/dash characters (captured), then a literal dot, then 2 or more lowercase letters (captured), then end of string.' Understanding each piece makes debugging and refining patterns much faster than trial and error alone.
Pattern (\w+)og tested against 'the dog and the frog logged' with flag g: matches 'dog', 'frog', 'log' (3 matches total). The breakdown reads: '(\w+) → one or more word characters (captured group 1), og → literal "og"'. Switching the flag to gi also catches 'LOG' if the text contained uppercase.
Who it's for
Web programmers, software engineers, scriptwriters, and data parsers.
Core Features
- Lists every match in your text and a live total as you type the pattern.
- Plain-English breakdown explaining each token of the pattern (classes, quantifiers, anchors, groups).
- Toggle the JavaScript flags (global, case-insensitive, multiline, sticky).
- Inline errors for invalid expressions; runs entirely in your browser.
🛡️ No tracking — your inputs, keys, and details never leave this client sandbox.
What do regex flags do?
Flags modify how the pattern matches. g (global) finds every match in the text instead of stopping after the first. i (case-insensitive) treats uppercase and lowercase as equal, so /hello/i matches 'Hello', 'HELLO', and 'hello'. m (multiline) makes ^ and $ match the start and end of each line, not just the start and end of the whole string. s (dotAll) makes the . metacharacter match newline characters as well as all others — by default, . does not match \n.
What is the difference between a greedy and lazy quantifier?
Greedy quantifiers (*, +, {n,}) match as much text as possible. Lazy (or reluctant) quantifiers (*?, +?, {n,}?) match as little as possible. For example, on '<b>bold</b> and <i>italic</i>', the pattern <.+> greedily matches the entire string from the first < to the last >. The lazy pattern <.+?> matches '<b>', '</b>', '<i>', and '</i>' separately. Choosing the right quantifier is often the key to avoiding unexpected over-matching.
How do capture groups work?
Parentheses create a capturing group. When the pattern matches, the text matched by each group is captured separately, numbered left to right starting at 1. For example, (\w+)@(\w+) applied to 'user@example' captures group 1 = 'user' and group 2 = 'example'. These captures can then be referenced in replacements as $1, $2, etc. Non-capturing groups (?:…) group without capturing, useful for applying a quantifier to a sequence without storing the match.
What is the \b anchor and when should I use it?
\b is a word boundary assertion — it matches the position between a word character (\w: letters, digits, underscore) and a non-word character. It does not consume any characters. The pattern \bcat\b matches 'cat' in 'the cat sat' but not the 'cat' inside 'concatenate'. It is essential when you want to match a whole word and not a substring embedded inside a longer word.
Why does my regex work in one language but not another?
Regex syntax and feature support vary between languages and engines. JavaScript's regex engine supports a wide set of features but lacks some found in Python (verbose mode, named groups with (?P<name>)) or PCRE (atomic groups, possessive quantifiers, conditionals). Named capture groups ((?<name>…)) and lookbehind assertions are supported in modern JavaScript but may not be available in older environments. This tool tests JavaScript regex specifically (using the browser's built-in engine), so results match what you would see in a Node.js or browser JavaScript context.
What most developers get wrong about regular expressions
Most developers learn regex as a lookup skill — they copy a pattern from Stack Overflow, test it against a few examples, and ship it. The problem is that a pattern that works on five test cases can catastrophically fail on the sixth. The most dangerous failure mode is not a wrong match but a performance failure: certain patterns on certain inputs cause exponential backtracking in NFA-based engines, hanging the browser or server for seconds or minutes. This is called ReDoS (Regular Expression Denial of Service) and it has caused production outages at companies including Cloudflare. Understanding why backtracking happens — not just what patterns match — is the difference between a developer who uses regex safely and one who creates time bombs.
How experts use regex tools differently than beginners
Beginners test a pattern against the happy path and call it done. Experts test edge cases first: the empty string, a string of all the same character, a pathologically long input, and inputs designed to maximize backtracking. They check whether their pattern is greedy or lazy and whether that choice is intentional. They use the plain-English explainer to verify each token does what they intend, not just that the whole pattern matches expected inputs. They also prefer specific character classes over the catch-all dot metacharacter and use anchors (^ and $) aggressively to limit the search space.
How the JavaScript regex engine works
JavaScript uses a backtracking NFA (non-deterministic finite automaton) engine. When matching, it tries to find a path through the pattern that successfully matches the input. When a greedy quantifier matches too much, the engine backtracks — it gives back matched characters and tries shorter matches. This makes regex powerful but also capable of 'catastrophic backtracking' on pathological patterns: a poorly constructed regex on crafted input can cause exponential time complexity, hanging the browser. Common causes are nested quantifiers on overlapping character classes, such as (a+)+.
Practical uses of regex
Regex is used extensively for: form validation (email addresses, phone numbers, postal codes), log parsing and data extraction, syntax highlighting in code editors, URL routing in web frameworks, search-and-replace in text editors, and data transformation in ETL pipelines. Understanding regex well — particularly how quantifiers, anchors, and groups interact — is one of the most broadly applicable skills in software development.