Regex Tester & Validator
Test regular expressions live: matches highlighted in your text, capture groups, flags and a token breakdown.
Matches
| # | Match | Line | Column |
|---|---|---|---|
| Enter a pattern to see what it matches. | |||
Regex breakdown
| Token | Explanation |
|---|---|
| Enter a pattern to see it explained. | |
Tests a regular expression against your text as you type: it reports whether the pattern is valid, highlights each match in the text, lists every match with its line, column and capture groups, by number and by name, and breaks the pattern into tokens with a plain explanation of each. It uses JavaScript's regex engine, in your browser.
How to use it
Type the pattern without surrounding slashes — \d+, not /\d+/g — and set flags with the switches:
- Global (g) — find every match; off, only the first. On by default.
- Ignore case (i) — letters match either case.
- Multiline (m) —
^and$match at the start and end of each line, not only of the whole text. - Dot matches newline (s) —
.also matches line breaks. - Unicode (u) — full Unicode matching, needed for
\p{L}classes and emoji.
Matches are tinted in the test string, neighbours told apart by an underline, and an empty match shows as a thin line. In the table, each capture group shows by name, or by number when it has none, with its value in quotes: "" for a group that matched nothing, and — for one that took no part. Columns count from 1. The table lists the first 1,000 matches; the count above it covers them all. Matching that takes longer than 1 second is stopped with a note: nested quantifiers such as (a+)+ double their running time with each extra character of text they almost match. The breakdown lists each token with what it matches, reading ^, $ and . by the flags that are on; a character class is described as a whole.
Engine differences
Patterns run on JavaScript's engine, which behaves like most modern ones for everyday patterns. Some features differ elsewhere: possessive quantifiers and atomic groups exist in PCRE and Java but not in JavaScript, and Python and Go name groups differently. Test in the engine you will deploy to when using advanced features.
Examples
Why the global flag matters
- Pattern
- \d+
- Text
- Order 42 shipped 3 items
- With g flag
- "42", "3"
- Without g flag
- "42"
Without the global flag, matching stops at the first match.
Named groups split a date
- Pattern
- (?<year>\d{4})-(?<month>\d{2})-(?<day>\d{2})
- Text
- Due 2026-03-31, paid 2026-04-02
- Match 1
- 2026-03-31: year "2026", month "03", day "31"
- Match 2
- 2026-04-02: year "2026", month "04", day "02"
Each group is listed by its name. A name also makes the pattern easier to read later, and a replacement can use it as $<year>.
Common patterns
| Pattern | Matches | Example text | Found |
|---|---|---|---|
\d+ | One or more digits | "Order 42 shipped 3 items" | "42", "3" |
\b\w+@\w+\.\w+\b | A simple email address | "Mail anna@example.com today" | "anna@example.com" |
^\s+|\s+$ | Spaces at the start or end | " padded " | " ", " " |
\b[A-Z][a-z]+\b | Capitalised words | "Anna met Ben in Pune" | "Anna", "Ben", "Pune" |
#[0-9a-fA-F]{6}\b | Hex colour codes | "Use #1e90ff or #FFF" | "#1e90ff" |
See also
- Find and Replace — to use a tested pattern to replace text.