Regex Tester
Type a pattern and a test string to see matches highlighted instantly, with capture groups and positions listed below.
Contact us at support@example.com or sales@example.org. Invalid: not-an-email
- #1 at index 14
support@example.com - #2 at index 37
sales@example.org
Common patterns
- Email address
[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,} - URL
https?:\/\/[^\s/$.?#].[^\s]* - IPv4 address
\b(?:\d{1,3}\.){3}\d{1,3}\b - Date (YYYY-MM-DD)
\d{4}-\d{2}-\d{2} - Time (HH:MM)
\b([01]\d|2[0-3]):[0-5]\d\b - Integer or decimal
-?\d+(?:\.\d+)? - Hex color
#(?:[0-9a-fA-F]{3}){1,2}\b - Whitespace-trimmed word
\S+
Patterns run with the JavaScript RegExp engine, entirely in your browser.
How it works
- Enter your regular expression in the pattern field and tick the flags you need (g, i, m, s, u).
- Paste or type your test string in the text area below the pattern.
- Read the highlighted preview and the match list, which shows each match’s index and capture groups.
Frequently asked questions
- Which regex syntax does this tester use?
- It uses the JavaScript (ECMAScript) regular expression engine built into your browser. That means lookahead, lookbehind, named groups, and Unicode property escapes (with the u flag) all work exactly as they do in Node.js and browser code. Syntax specific to other engines, such as PCRE recursion or possessive quantifiers, is not supported.
- What do the g, i, m, s, and u flags do?
- The g flag finds every match instead of stopping at the first; i makes matching case-insensitive; m lets ^ and $ match at line breaks; s lets the dot match newline characters; and u enables full Unicode mode, which is needed for property escapes like \p{L} and correct handling of characters outside the basic plane.
- Is my text sent to a server?
- No. The pattern and test string are evaluated entirely in your browser using the native RegExp engine, and nothing is transmitted over the network. You can safely test patterns against logs, config files, or other text you would not want to paste into an online service that uploads data.
- Why does my pattern show an error?
- The error message comes straight from the JavaScript engine, so it points at real syntax problems: an unclosed group or bracket, an invalid escape, or a quantifier with nothing to repeat. Some escapes that are tolerated normally become errors in Unicode mode, so try removing the u flag if a previously working pattern suddenly fails.
- How do capture groups appear in the results?
- Each match in the list shows its zero-based character index and the full matched text, followed by every capture group in order. Named groups written as (?<name>...) display their name next to the captured value, and groups that did not participate in the match are shown as empty.
About this tool
This regex tester lets you build and debug regular expressions against real sample text with immediate feedback. As you edit the pattern or the test string, the preview re-renders with every match highlighted, and a list below breaks down each match with its character position and captured groups. Invalid patterns never fail silently: the exact error message from the regex engine appears under the pattern field, so you can see whether the problem is an unclosed group, a bad escape, or a stray quantifier.
Everything runs client-side in your browser using the native JavaScript RegExp engine — no text is uploaded anywhere. This makes the tool safe for testing patterns against production log lines, email lists, or configuration snippets that contain sensitive values. It also means the behavior you see here is exactly what you will get in JavaScript or TypeScript code, including the effect of each flag combination and of Unicode mode.
Typical uses include validating an email or URL pattern before shipping it, working out the right capture groups for extracting timestamps from logs, testing multiline patterns for parsing config files, and checking that a search-and-replace pattern matches only what you intend. The common-patterns reference includes ready-made expressions for emails, URLs, IP addresses, dates, and more, which you can use as starting points.
A few practical tips: enable the g flag while exploring so you see all matches rather than just the first; add the m flag when your test string has multiple lines and you anchor with ^ or $; and prefer specific character classes over the dot where you can, since overly broad patterns are the most common source of false matches. If a pattern matches more than expected, shorten the test string until the unwanted match disappears — that usually isolates the offending part quickly.