Regex Tester

In short: the pattern \d+ with the g flag finds every run of digits: in the sample text it matches 123 at position 3 and 45 at position 9, then 66 and 2026, 01 and 15. Every match below shows its text, position and capture groups.

A notation for describing text instead of typing it

A regular expression is a tiny programming language for one job: describing a pattern of text precisely enough that a machine can find it, check it or pull it apart. Instead of searching for the literal string "2026-01-15", you write \d{4}-\d{2}-\d{2} — four digits, a dash, two digits, a dash, two digits — and it finds every date-shaped string ever written, including the ones that do not exist yet. That jump from literal to pattern is why regex powers search-and-replace, input validation, log analysis, text scraping and half the plumbing of every programming language. It is also why regex has its reputation: the notation is dense, write-only-looking, and unforgiving of a single misplaced character. The only reliable way to build a pattern is exactly what this page does — test it against real text, watch what it matches, and adjust until the matches and the intention agree.

This tester runs the JavaScript engine built into your browser and reports everything the engine finds: each match with its character position, the capture groups inside it, and a live find-and-replace preview when you supply a replacement. The pattern library below covers the requests that come up daily — emails, URLs, dates, hex colours, IP addresses — each with its limits stated, because a borrowed pattern you do not understand is a bug waiting for its first unusual input.

The essential syntax

PatternMeansPatternMeans
.any character (except newline)\d \w \sdigit / word character / whitespace
* + ?0 or more / 1 or more / 0 or 1\D \W \SNOT digit / word / whitespace
{n} {n,m}exactly n / between n and m[abc] [a-z]one of a set / a range
*? +?lazy versions (as little as possible)[^abc]anything EXCEPT the set
^ $start / end (of string, or line with m)(...) (?:...)capture group / plain group
a|ba or b\bword boundary

Worked examples

Finding numbers: \d+ with flag g on "abc123def45" returns 123 at index 3 and 45 at index 9 — the + makes each match a whole run of digits, and g keeps the engine going after the first.

Finding dates: \d{4}-\d{2}-\d{2} on "pay by 2026-01-15" returns 2026-01-15. Note what it also returns: 9999-99-99 would match too — the pattern checks shape, not sense. Real validation needs a range check after the match.

Splitting an email: ^([^@]+)@([^@]+)$ on "[email protected]" matches the whole address, with group 1 = john and group 2 = example.com — the [^@]+ trick ("one or more of anything except @") is the workhorse of practical patterns.

Find and replace: pattern (\w+)@old\.com with replacement [email protected] migrates every address from the old domain to the new one — try it in the tool.

Pattern library (with honest limits)

JobPatternLimit
Email (practical)[^\s@]+@[^\s@]+\.[^\s@]+Catches realistic addresses; only a confirmation mail truly validates
URLhttps?://[^\s]+Also matches trailing punctuation — trim after matching
Date (ISO shape)\d{4}-\d{2}-\d{2}Shape only; 2026-99-99 passes
Hex colour#(?:[0-9a-fA-F]{3}){1,2}3- and 6-digit forms; add {8} variants if alpha matters
IPv4 (loose)\b(?:\d{1,3}\.){3}\d{1,3}\b999.1.1.1 passes; range-check octets in code
Whole word\bcat\bFinds "cat" but not the cat in "concatenate"

Frequently asked questions

What do the regex flags g, i, m and s mean?

g (global) finds every match instead of stopping at the first. i makes matching case-insensitive. m (multiline) makes ^ and $ match at line boundaries, not just the start and end of the whole text. s (dotAll) lets the dot match newline characters too, which it normally skips. Two more exist in JavaScript: u enables full Unicode behaviour, and y makes matching sticky — each match must begin exactly where the last one ended.

Why does my regex match too much?

Almost always greediness: quantifiers like + and * take as much as they possibly can. The pattern ".*" run against "one" and "two" matches the whole string — "one" and "two" — because .* runs to the last quote. Add a question mark for the lazy version — ".*?" stops at the first closing quote. The other classic cause is an unescaped dot: '.' matches any character, so 1.5 also matches '125' and '1x5'; write 1\.5 when you mean a literal decimal point.

What is a capture group?

A part of the pattern wrapped in parentheses, which the engine remembers separately from the whole match. In ^([^@]+)@([^@]+)$ run against an email address, group 1 captures the part before the @ and group 2 the domain — which is how validation code extracts pieces instead of just answering yes or no. Groups are numbered by their opening parenthesis, left to right, and in replacement text they are referenced as $1, $2 and so on. (?:...) groups without capturing.

Can a regex validate an email address properly?

Not completely. The full legal syntax of an email address is far stranger than common sense suggests, and the only perfectly correct pattern is famously hundreds of characters long — and still cannot tell you whether the mailbox exists. The pragmatic pattern used in this tool's library catches the realistic cases (something, an @, a domain with a dot). Real systems then confirm by sending mail to the address, which is the only validation that actually proves anything.

Why does my regex freeze or take forever?

Catastrophic backtracking: nested quantifiers such as (a+)+ or (.*)* force the engine to try exponentially many ways to divide the text when a match nearly succeeds but ultimately fails. The fix is to make the inner and outer patterns claim different characters, use a lazy or atomic approach, or restructure so a failure is discovered quickly. If a pattern hangs in this tester, that is the bug to look for — real user input will find it too.

Note: This tester uses the JavaScript regex engine. Other flavours (PCRE, Python, Java) share the core syntax but differ in details — named groups, lookbehind support and flag letters among them. Check your platform's documentation before shipping a pattern.

Related tools

Examples and semantics last verified: 24 November 2026. Everything is calculated in your browser — nothing you type is sent anywhere.