Temp Mail Logo

Temp Mail safeguards your privacy while keeping your inbox free from spam.

🔍 Live Matching · Capture Groups · Flags · Replace · Pattern Library

Regex Tester

Free online regular expression tester. Test and debug JavaScript regex with live match highlighting, capture group display, all flags (g, i, m, s, u), replace preview, and a library of 10 common patterns. Results update as you type.

✓ Live highlighting✓ Capture groups✓ All flags✓ Replace mode✓ Pattern library
Regular Expression
//g
Flags:
Presets:
Test String
Contact us at support@example.com or sales@company.co.uk Invalid: @nodomain.com or user@
2matches found
1
support@example.comindex 14, 33
2
sales@company.co.ukindex 37, 56
What this tool does

Free regex tester: test and debug JavaScript regular expressions with live highlighting and capture groups

How the regex tester works, what each feature does, and tips for debugging common regex problems

This regex tester runs JavaScript's native RegExp engine directly in your browser, giving results that exactly match what you'd get in a Node.js backend, a React application, or any browser-based JavaScript code. Results update live as you type in the pattern field. No button click needed. Every match is highlighted in the test string with colour-coded segments so you can instantly see what is and isn't being captured, which is far more useful than a simple yes/no match result.

The tool supports all six JavaScript regex flags: g (global, find all matches), i (case insensitive), m (multiline, ^ and $ per line), s (dotAll, dot matches newlines), u (Unicode, enables \\p property escapes), and y (sticky). Flags can be combined freely and are toggled with one click. The current active flag string is shown next to the pattern to make it easy to copy the complete regex literal for use in code.

Capture groups, both numbered and named, are shown for each match, making this tool especially useful for extracting structured data like dates, emails, or version numbers from text. Replace mode previews substitution output using the same pattern, letting you test replacement strings with group references ($1, $2, $<name>) before writing the code. The preset library provides 10 ready-to-use patterns for the most common regex tasks.

Features and capabilities
Live Matching
Results update instantly as you type in the pattern field. No button click, no delay.
Visual Highlighting
Every match colour-coded in the test string so you can see exactly what the pattern captures and where boundaries fall.
All 6 Flags
Toggle g, i, m, s, u, y with one click. Active flags shown next to pattern for easy copying into code.
Capture Groups
Numbered and named groups displayed per match. Essential for regex that extracts structured data.
Match Positions
Start and end character index shown for every match. Useful for string slicing and position-aware processing.
Replace Preview
Test substitution strings with $1/$2/\$<name> group references and see the full replaced output instantly.
Error Display
Invalid regex syntax shown immediately with the exact error message from the JS engine. No silent failures.
Pattern Library
10 pre-built presets for email, URL, IPv4, phone, date, hex color, HTML tags, whitespace, duplicate words, JWT.
Up to 50 Matches
Displays up to 50 individual match results with full group detail. Shows total count if more are found.
100% Client-Side
All regex processing runs in your browser. Test strings with sensitive data never leave your device.
Examples

Regex examples: email validation, named groups, lookaheads, and common patterns

Annotated regex examples showing pattern structure, flags, and what each part matches
Email ValidationEmail address regex: matching all standard formats
Pattern: [a-zA-Z0-9._%+\-]+@[a-zA-Z0-9.\-]+\.[a-zA-Z]{2,} Flags: g Test: Contact us at support@example.com or sales@company.co.uk Invalid: @nodomain.com or missing@.com Matches: support@example.com sales@company.co.uk
This pattern matches most real-world email addresses: one or more characters from the allowed set before @, a domain name, a dot, and a TLD of at least 2 characters. It won't match addresses starting with @ or with a missing domain. For production use, email validation via a confirmation email is more reliable than regex alone, since the RFC 5321 spec allows edge cases this pattern doesn't handle.
Named GroupsNamed capture groups: extracting date components
Pattern: (?<year>\d{4})-(?<month>0[1-9]|1[0-2])-(?<day>0[1-9]|[12]\d|3[01]) Flags: g Test: Order placed on 2024-01-15, ships on 2024-02-03. Invalid date: 2024-13-01 (no match) Groups: Match 1 → year:2024, month:01, day:15 Match 2 → year:2024, month:02, day:03
Named capture groups (?<name>...) let you extract components by name rather than index. The month group uses a character class to enforce 01-12 and the day group enforces 01-31, so invalid dates like 2024-13-01 don't match. In JavaScript, access named groups via match.groups.year, match.groups.month etc.
LookaheadPositive lookahead: match numbers followed by a unit
Pattern: \d+(?=px|em|rem|vh|vw) Flags: g Test: font-size: 16px; margin: 2rem; width: 100vw; padding: 10px; height: 50vh; Matches: 16 (followed by px) 2 (followed by rem) 100 (followed by vw) 10 (followed by px) 50 (followed by vh)
A positive lookahead (?=...) matches a position followed by the specified pattern without including it in the match. Here (?=px|em|rem|vh|vw) ensures we only match numbers that are CSS values. The unit is required but not captured in the match itself. This is useful for extracting values from CSS, config files, or structured text where context determines meaning.
FAQ

Frequently asked questions about regular expressions and regex testing

Common questions about regex syntax, flags, capture groups, and debugging patterns
What regex flavour does this tester use?
This tester uses JavaScript's built-in RegExp engine, which implements a subset of the PCRE (Perl Compatible Regular Expressions) standard. It supports all common regex features: character classes, quantifiers, anchors, lookaheads and lookbehinds, named capture groups, backreferences, and the standard flags (g, i, m, s, u, y). It does not support some PCRE-specific features like possessive quantifiers, atomic groups, or variable-length lookbehinds (though ES2018+ added fixed-length lookbehinds). Results match exactly what you'd get in a Node.js, browser JavaScript, or TypeScript application.
What do the regex flags mean?
g (global). Find all matches instead of stopping at the first. i (case insensitive). Match uppercase and lowercase equivalently. m (multiline). Make ^ and $ match the start and end of each line, not just the whole string. s (dotAll). Make the dot (.) match newlines as well as other characters. u (unicode). Enable full Unicode support for \p{} property escapes. y (sticky). Match only from lastIndex, not searching forward. You can combine flags freely. Gi finds all matches case-insensitively, gm matches across multiple lines.
How do capture groups work?
A capture group is a part of the regex wrapped in parentheses that captures the matched text as a separate result. For example, the pattern (\d{4})-(\d{2})-(\d{2}) applied to '2024-01-15' captures three groups: '2024', '01', and '15'. Named capture groups use (?<name>...) syntax. For example (?<year>\d{4}) names the first group 'year'. Groups are useful for extracting specific parts of a match, like pulling the domain from an email address or the year from a date string. This tool displays all capture groups alongside each match.
What is the difference between greedy and lazy quantifiers?
Greedy quantifiers (*, +, ?, {n,m}) match as much text as possible. Lazy quantifiers (*?, +?, ??, {n,m}?) match as little text as possible. For example, the pattern <.+> applied to '<b>bold</b>' greedy matches the entire string '<b>bold</b>' (from the first < to the last >). The lazy version <.+?> matches '<b>' (stopping at the first >). Greedy is the default. Add ? after any quantifier to make it lazy. This matters when matching HTML tags, quoted strings, or any content with nested delimiters.
What is a lookahead and lookbehind?
Lookaheads and lookbehinds are zero-width assertions that match a position based on what follows or precedes it, without including that text in the match. A positive lookahead (?=...) matches a position followed by the specified pattern. A negative lookahead (?!...) matches a position NOT followed by the pattern. Similarly for lookbehinds: (?<=...) and (?<!...). Example: \d+(?= dollars) matches numbers followed by ' dollars' but doesn't include ' dollars' in the match. These are essential for extracting values without their context strings.
How do I match special characters literally?
Characters with special meaning in regex, . * + ? ^ $ { } [ ] | ( ) \. Must be escaped with a backslash to match them literally. For example, to match a literal dot, use \. instead of . (which matches any character). To match a literal backslash, use \\. To match a literal opening parenthesis, use \(. In JavaScript string literals, you need to double-escape: the pattern for a literal dot in a JS string is '\\.'. In this tool's pattern field, use single escaping. Enter \. to match a literal dot.
How do I test a multiline string?
Paste or type multiple lines directly into the Test String text area. It supports newlines. For multiline matching, enable the m flag so that ^ and $ match the start and end of each line. Enable the s flag (dotAll) if you want the dot to match newline characters. Without s, a dot matches everything except \n, so patterns like .+ won't cross line boundaries. Without m, ^ only matches the very start of the entire string and $ only matches the very end.
Why is my regex matching too much or too little?
Over-matching (too much) is usually caused by greedy quantifiers or the dot matching more than expected. Try making quantifiers lazy (add ?) or use character classes instead of dots. Under-matching (too little) is often caused by missing the g flag (only first match returned), anchors that are too strict (^ or $ not matching as expected without the m flag), or character classes that don't include all needed characters. The visual highlighting in this tool makes it immediately clear exactly what is and isn't being matched, which is the fastest way to debug both problems.

Need a disposable email address?Stop exposing your real inbox. Get a free instant throwaway email with no signup and no trace.

Get Free Temp Mail →