ToolsForWeb

Regex Tester

Write a pattern, paste sample text and see every match highlighted as you type, with each match's capture groups listed underneath. Toggle the g, i, m, s and u flags; an invalid pattern returns the regex engine's own error message. Runs entirely in your browser.

Loading tool…

About this tool

Write a pattern, paste sample text and see every match highlighted as you type, with each match's capture groups listed underneath. The g, i, m, s and u flags are toggles, and an invalid pattern returns the regex engine's own error message so you can fix it directly. The engine is JavaScript's, so results match what your browser and Node will do — other languages have small differences.

When to use it

Testing a validation pattern against real sample data before it ships.
Debugging a pattern that matches more or less than expected, group by group.
Pulling values out of logs or scraped text with capture groups.
Learning what a flag or construct changes by toggling it and watching the matches.

Questions

What do the flags mean?

i ignores case, m makes ^ and $ match at line boundaries instead of the whole string, s lets . match newlines, and u enables full Unicode handling such as \p{...} property classes. g is implied: the tester always highlights every match.

Why do I see every match when the g flag is off?

The tester adds g internally so the highlighter can show all matches. For first-match-only semantics in your own code, take the first result and drop the flag there.

Why does my lookbehind fail while my lookahead works?

Lookbehind — (?<=...) and (?<!...) — arrived in JavaScript years after lookahead and needs a modern browser or Node 8.3+. If the engine reports an invalid group, it is the age of the runtime, not your pattern.

Why does . only match half of this emoji?

Without the u flag, JavaScript treats characters outside the BMP as two UTF-16 code units, so a single . matches half a symbol. Turn u on and use \p{...} classes for symbol-level matching.

How do I validate an email address with a regex?

A fully RFC-compliant email regex is a famous rabbit hole, and almost nobody needs it. For the usual job — checking that input looks like an email — a practical pattern is \S+@\S+\.\S+: something, an @, something, a dot, something. Run it on the default sample text and it picks up support@example.com. To require the whole input be nothing but an address, anchor it — ^\S+@\S+\.\S+$ — and add the m flag so the anchors apply per line. For a real signup flow, treat the regex as a lint and send a confirmation mail; the only reliable email validation is a delivered email.

What are good patterns for dates and URLs?

ISO dates: \d{4}-\d{2}-\d{2} finds 2026-08-01 in the sample's invoice line — and also matches structurally valid nonsense like 2026-13-99, because a regex checks shape, not whether the month exists. URLs: https?:\/\/\S+ matches an http(s) link up to the first whitespace; ^https?:\/\/[a-z0-9.-]+\.[a-z]{2,}(\/\S*)?$ with the i flag validates that a whole line is a plausible link. Anchor with ^ and $ plus the m flag whenever a pattern must match whole lines rather than fragments.

What does \b (a word boundary) actually match?

A position, not a character — the spot between a word character ([A-Za-z0-9_]) and a non-word character or the edge of the string. \bcat\b matches the cat but not category or scatter; \bcat matches both cat and category, because it only demands a boundary at the start. One quirk: underscore counts as a word character, so \b sees no boundary in snake_case_words — use (?<!\w)cat(?!\w) when you need a stricter edge.

How do named capture groups work?

Named groups — (?<year>\d{4}) — give a capture a label you can read back in code as match.groups.year instead of remembering that $2 was the month. This tester lists groups by number, so a named group appears as $1 like any other; the label is for your own code, not the display. Try (?<year>\d{4})-(?<month>\d{2}) against the sample date: one match, two groups, each retrievable by name in Node or the browser.

Related tools