DevToolsForYou
Private by defaultRuns in your browser

Regex tester

Enter a pattern and test string to instantly see all matches highlighted, with capture groups listed below.

//g
Matches highlighted
Matches will be highlighted here…
Quick samplesCommon patterns
Regex Tester

About this tool

A regular expression is a small pattern language for describing shapes of text — a sequence of digits, a word at a boundary, everything between two delimiters. Writing one is rarely the hard part; knowing what it actually matched is. A pattern that looks right against the example in your head will happily match something else entirely three lines down a real input file, and the failure is silent. Testing against real data, with every match highlighted, is the fastest way to see the difference between what you meant and what you wrote. This tester uses the browser's own RegExp engine, so it follows ECMAScript rules: the same behaviour you will get in Node and in the browser, but not identical to PCRE, Python's re, or Go's RE2. Lookbehind is supported in modern browsers, named groups use the (?<name>...) syntax, and there are no possessive quantifiers or recursion. Matches are highlighted live as you type, with capture groups listed for each hit, and the g, i, m, and s flags are toggleable. Everything runs locally in your browser.

No signup requiredRuns in your browserInstant results
How to use
  1. 1

    Enter your regular expression pattern in the pattern field (without slashes).

  2. 2

    Set any flags you need: g for global, i for case-insensitive, m for multiline.

  3. 3

    Paste your test string below — all matches are highlighted in real time.

  4. 4

    Hover a match to see the captured groups.

Why use this tool?
  • →

    Test and debug regular expressions before adding them to your codebase.

  • →

    Verify that a pattern matches the exact strings you expect without edge cases.

  • →

    Inspect capture groups to confirm your regex extracts the right substrings.

ExamplesInput → output

Match all numbers

InputPattern: \d+ | Text: Order 123 and item 456
OutputMatches: 123, 456

Match email address

InputPattern: [\w.+]+@[\w.]+\.[a-z]{2,} | Text: contact@example.com
OutputMatch: contact@example.com

Match words starting with capital

InputPattern: \b[A-Z]\w* | Text: Alice and Bob went to London
OutputMatches: Alice, Bob, London
Common errorsAnd how to fix them

Only the first match is highlighted

Cause: The global flag is off. Without g, the engine stops at the first match, which is also why exec and match behave so differently depending on the flag.

Fix: Enable the g flag. Be aware that a global regex object carries a mutable lastIndex in JavaScript, so reusing one across calls in your own code can skip matches — construct a fresh regex or reset lastIndex.

The pattern hangs or the page freezes on a long input

Cause: Catastrophic backtracking. Nested quantifiers over overlapping character classes — patterns shaped like (a+)+ or (\s*\w+)* — make the engine try exponentially many ways to match before giving up on a near-miss.

Fix: Avoid nesting one quantifier inside another over the same characters. Make inner classes mutually exclusive, anchor the pattern, or replace the ambiguous part with a negated class such as [^,]+ rather than .*.

The pattern works here but fails in Python, Java, or grep

Cause: Regex flavours differ. Escape rules, lookbehind support, named-group syntax, and whether \d matches non-ASCII digits all vary between engines.

Fix: Test in the flavour you will deploy to. Watch double-escaping in particular: a pattern written as a string literal in Java or Python needs each backslash doubled, so \d becomes \\d in the source.

Frequently asked questionsCommon questions answered

These answers explain common regex tester tasks, expected input formats, and edge cases so both visitors and search engines can understand what this tool does.

Which regex flavour does this tool use?

This tool uses JavaScript's built-in RegExp engine, which follows the ECMAScript standard. It supports all standard flags: g (global), i (case-insensitive), m (multiline), and s (dotAll).

What are capture groups?

Capture groups are parts of a regex wrapped in parentheses. They let you extract specific substrings from a match. This tool lists each group's value for every match found.

Why does my pattern match nothing?

Common causes include forgetting to escape special characters like . or *, using anchors (^ or $) without the multiline flag, or a pattern that is more specific than the test string.

What regex flags does this tool support?

The tester supports the standard JavaScript regex flags: g (global — find all matches), i (case-insensitive), m (multiline — ^ and $ match line starts and ends), and s (dotAll — dot matches newline characters). You can combine flags as needed.

How do I test a regex for email or URL validation?

Paste your regex pattern in the pattern field, then paste sample email addresses or URLs in the test string field. The tool highlights every match so you can immediately see which inputs pass and which do not, without running code.