regex tester

How to use the regex tester

  1. Type your regular expression in the pattern field. Add flags (g for global, i for case-insensitive, m for multi-line, s for single-line dotall).
  2. Paste the test string in the input area. Matches highlight in real time as you type.
  3. Use the explanation panel to read what each part of the pattern does — useful when reviewing somebody else's regex.
  4. View captured groups, named groups, and the full match for each hit.
  5. Click 'Replace' to test substitution patterns with `$1`, `$2`, etc., and see the resulting string.

When to use it

Use it whenever you're crafting a regex for log parsing, form validation, find-and-replace operations, or rewriting URL paths. The instant highlighting catches greedy/lazy mistakes immediately. Alternative: regex101.com is the dominant tool with extensive flavor support; this one is faster for the JavaScript flavor and runs offline once the page loads.

Example

A common email validator and its captures:

Pattern: ^([\w.+-]+)@([\w-]+\.[\w.-]+)$
Flag: i

Input:  [email protected]
Match:  [email protected]
$1:     alice
$2:     example.com

Frequently asked questions

What is a regular expression?
A pattern language for matching text. Originated in 1950s automata theory, became practical in Unix tools (grep, sed, awk), now built into every major programming language. Powerful for parsing, validation, and search-and-replace.
Which regex flavor does this tool use?
JavaScript (ECMAScript 2018+). Most patterns work across PCRE, Python, and Java with minor adjustments — but lookbehinds, named groups, and Unicode property escapes have flavor-specific syntax.
Why doesn't my pattern match?
Common causes: forgot to escape special characters (`.`, `+`, `*`, `?`, `(`, `)`, `[`, `]`, `\`, `/`); used `*` (zero or more) when you meant `+` (one or more); forgot the `g` flag for global matches; mixed up greedy `.*` vs lazy `.*?`.
How do I capture multiple groups?
Wrap each section in parentheses: `(\d{4})-(\d{2})-(\d{2})` for a date. Access as `$1`, `$2`, `$3` in replace mode, or `match[1]`, `match[2]`, `match[3]` in code.
What's the difference between greedy and lazy matching?
Greedy (`.*`) matches as much as possible. Lazy (`.*?`) matches as little as possible. Use lazy when extracting content between delimiters: `<.*?>` matches a single tag, `<.*>` would match from the first `<` to the last `>`.
Can I save my regex?
The pattern persists in the URL fragment as you edit, so bookmarking saves it. For permanent storage, paste into a Gist or your project repo.

Related tools

Last updated: 2026-04-27