Regex Tester
Type a pattern, paste some text, and see every match and capture group as you go.
Output
Paste or type above to see the result here.
Your files stay on your device
This tool runs entirely in your browser. What you paste is processed on your device and is never sent to a server, so it is safe to use with tokens, keys and unpublished text.
Example
Example: pulling the state and ZIP code out of US addresses
A pasted list, one address per line: “Emily Carter, Springfield, IL 62704”, “Michael Brooks, Portland, ME 04101-2214”, “Sarah Nguyen, Austin, TX 78701” and a stray line “Order 12345678 shipped”. Pattern \b([A-Z]{2}) (\d{5})(?:-(\d{4}))?\b, flag g.
- ([A-Z]{2}) takes the two capital letters of the state, then a space and (\d{5}), the five digits; (?:-(\d{4}))? adds the ZIP+4 ending when there is one, and (?: keeps the hyphen out of the groups.
- Each match is listed with @ and its position, then $1, $2 and $3; a group that matched nothing is left empty. Named groups would be listed a second time under their names.
- The order number is not matched: eight digits with no state in front, and \b stops a match from starting inside a longer number.
- Without g, only #1 is listed and the count is 1 match.
| Match | Position | $1 (state) | $2 (ZIP) | $3 (+4) |
|---|---|---|---|---|
| #1 “IL 62704” | @27 | IL | 62704 | (empty) |
| #2 “ME 04101-2214” | @62 | ME | 04101 | 2214 |
| #3 “TX 78701” | @98 | TX | 78701 | (empty) |
3 matches. The ZIP keeps its leading zero, 04101, because a regular expression returns text, not numbers. The same pattern works in JavaScript code as /…/g, since this tester runs the browser’s own engine.
How it works
- Enter your regular expression in the Pattern field, without the surrounding slashes. For example \b\w+@\w+\.\w+\b to find email-like strings.
- Set the flags you need: g for all matches, i for case-insensitive, m for multi-line anchors, s so that a dot matches newlines, u for full Unicode support.
- Paste the text you want to search into the input box. Log lines, CSV rows, HTML, whatever your pattern is meant to run against.
- The result appears as you type. The output lists each match with its position and every numbered or named capture group, so you can confirm the pattern grabs exactly what you expect.
Frequently asked questions
- Which regex flavor does this tester use?
- It uses the JavaScript (ECMAScript) engine built into your browser. Lookbehind, named groups (?<name>...), Unicode property escapes \p{...} with the u flag, and the s flag are all supported in current browsers. Features specific to PCRE, Python or Java, such as possessive quantifiers or inline modifiers like (?i), are not available.
- Why do I only see the first match?
- Without the g flag, a regular expression stops after the first match. Add g to the Flags field to list every occurrence in the text.
- What do the flags mean?
- g: global, find all matches. i: ignore case. m: ^ and $ match at the start and end of each line rather than the whole text. s: the dot also matches line breaks. u: treat the pattern and text as Unicode code points, needed for emoji and \p{L} classes. y: sticky, each match must start exactly where the last one ended: with g the matches run on from the start of the text, without g there is one match, at the very start or none.
- Why does my pattern hang or take a long time?
- Some patterns, especially a quantified group inside another quantifier such as (a+)+ run on text that does not match, cause catastrophic backtracking. JavaScript has no possessive quantifiers or atomic groups, so make the pattern more specific instead: [^,]* rather than .* inside a field, no nested quantifiers, and ^ or \b anchors to cut down where matching is tried.
- What does the number after @ mean?
- The position where the match starts, counting from 0 at the first character of the text. It counts UTF-16 units, as JavaScript does, so an emoji before the match counts as 2.
- Why is each named group listed twice?
- Named groups are numbered as well, so a match lists $1, $2… first and then the same values under their names. A group that took no part in the match, like an optional ZIP+4, shows an empty value. Without g only the first match is listed, its groups the same way.
- Is my sample text uploaded anywhere?
- No. Matching runs entirely in the browser. You can safely paste production logs, personal data or source code; the text never leaves your device.
Related tools
{} JSON Formatter Paste JSON, get it indented, minified or validated instantly. Your data stays on this page. ∿ Base64 Convert text to Base64 and back, with correct UTF-8 handling and an optional URL-safe alphabet. • UUID Generator Create UUID v4 or v7 identifiers in bulk, generated on your device with a secure random source. ◴ Cron Parser See 0 */6 * * 1-5 as the dates it will actually run, and what each field allows.