Skip to content
ToolForge
Developer Tools

Regular Expression Tester

Test regular expressions live. See match groups, named captures, indices and flags, try the replacement preview, and get an explanation of what each part of the pattern does.

Free, no sign-upRuns in your browserNothing uploaded

//gi
Presets:

Matches highlighted in place

ada@example.com, grace.hopper+dev@example.com

Matches (2)

#1at 0–15

0: ada@example.com

#2at 17–45

0: grace.hopper+dev@example.com

What this pattern does

  • [ ]Character class: matches any single character in the set. A leading ^ negates it.
  • \wA word character: letter, digit or underscore.
  • *Greedy quantifier: match as much as possible, then give back.
  • {n,m}Bounded repetition: an exact number or range of repeats.

Paste a pattern and a test string and you see every match immediately, highlighted in place, with the full and partial match broken out. Group 0 is the whole match, and every numbered and named group is listed with its own captured value and character offsets, which is the fastest way to find out why a group is coming back undefined.

Flags are toggles rather than text to remember: global, case-insensitive, multiline, dot-all, sticky, unicode and unicode-sets. The tool tells you when a flag is unavailable in your browser rather than silently ignoring it, since the last two are recent and a pattern written against a modern engine can fail in an older one.

The pattern is also explained. Each part is annotated in plain English - a word boundary, a lazy quantifier, a back-reference, a lookahead - so a pattern you copied from a forum becomes readable. That matters more than it sounds: most regex debugging is really just working out what someone else's pattern was supposed to do.

Regex Tester features

In-place match highlighting
Every match is highlighted in the test string with the full match, submatches and the surrounding unmatched regions visually distinct.
Full group breakdown
Group 0 plus every numbered and named capture with its value and start and end offsets, so undefined groups are obvious.
Live compile validation
Reports a syntax error immediately with the character position and the engine message instead of failing on submit.
Replacement preview
Shows the output of applying a replacement with $1, $2, $<name> and $& support before you use it in code.
Pattern explanation
Plain-English annotation of each construct: anchors, character classes, quantifiers, lazy versus greedy, groups, lookarounds and back-references.
Match timing
How long the pattern takes on your input, which surfaces catastrophic backtracking before it becomes an outage in production.
Flag support detection
Reports which of the modern flags your browser supports and refuses to silently drop one you thought you had enabled.
Presets library
Email, URL, IPv4 and IPv6, phone numbers, dates, credit cards, UUIDs, hex colours and more, as starting points.

How to use the Regex Tester

  1. Write your pattern

    Type into the pattern field. The live indicator shows whether it compiles, and gives the exact syntax error and position if it does not.

  2. Paste a test string

    Multi-line input works, and the multiline flag changes how ^ and $ behave. The match count and total matched characters are shown.

  3. Inspect the groups

    Each capture group is listed with its value and start and end offsets, named groups by name. A group with no value is called out, which is usually the bug you are hunting.

  4. Preview the replacement

    Enter a replacement string using $1, $2 and named captures to see the result before you put it in production code.

Frequently asked questions

Why is my group undefined?

Most often the group is inside a quantified block that did not participate in that particular match, or it is optional and the input took the path where it was skipped. Another common cause is that an alternation group has fewer branches than the group number implies. The group list flags undefined groups so you can see which one it is.

What is the difference between a greedy and a lazy quantifier?

A greedy quantifier takes as much as it can and then gives back, while a lazy one takes as little as possible. For the string 'aaa', /a+/ matches all three, but /a+?/ matches only the first. Use lazy when the trailing delimiter defines the boundary, as in /<.+?>/ matching a single HTML tag.

Why does my regex hang on certain inputs?

Catastrophic backtracking, caused by nested quantifiers over overlapping alternatives such as (a+)+. The match timing readout makes it visible. Fix it by making the alternatives mutually exclusive, by anchoring more precisely, or by rewriting to avoid nesting - an atomic group or a possessive quantifier, where supported, also solves it.

Should I use lookahead for validation?

For yes-or-no checks, a lookahead-only pattern such as /(?=...)/ is compact and fast. For email and similar structured formats, a named capture group with a readable pattern is far easier to maintain, and a regular expression is a poor substitute for real validation logic.

Are the results the same across JavaScript, Python and Java?

The core syntax is largely shared but not identical, and the differences are exactly where bugs live. JavaScript has no atomic groups or possessive quantifiers, Python's re module adds them, .NET adds a different set of named group syntaxes, and Unicode property escapes are supported in modern JavaScript and Python but not everywhere. Check your target engine before relying on a flag.

Is the regex executed on a server?

No. It compiles and runs against your test string inside the browser, using the same engine as the browser's own JavaScript, so behaviour matches client-side JavaScript exactly. A very large input or a badly written pattern can make the tab unresponsive, which is why timing is measured and reported.

Every tool, in one place

ToolForge has regex tester plus a growing set of image, colour and developer tools. All of them run locally in your browser, free and without an account.

Browse all tools