Introduction
Paste a pattern and a test string. The tester runs both through JavaScript's built-in RegExp engine and shows which characters matched, which capture groups fired, and where every match starts and ends. Most patterns need a few rounds against real samples before they hold up, and this tool keeps that loop tight: type, edit, see the result, repeat.
Regular expressions are still the fastest way to pull structured pieces out of messy text: email addresses in a log dump, UUIDs in a JSON blob, timestamps at the start of every line. Writing one correctly depends on small details — anchors, greedy versus lazy quantifiers, escape rules — and those details are much easier to spot when the engine highlights your mistakes in real time instead of failing silently later inside a script.
Everything runs locally in your browser. Patterns, test strings, and match results never leave the tab, which matters when the sample data includes production log lines, customer records, or anything else you would rather not paste into a server-side tester.
How to Use
- Type your regular expression into the pattern field — no surrounding slashes needed.
- Toggle flags (g, i, m, s, u) to control global matching, case sensitivity, multiline anchors, dotAll, and full Unicode support.
- Paste the text you want to match against into the test input. Matches are highlighted live as you type.
- Review the match list underneath. Each entry shows the matched substring, start and end index, and numbered or named capture groups.
- Fix the pattern if a match goes wider or narrower than expected, then copy the final regex into your code.
Examples
Three patterns that cover the most common situations: validating a field, pulling fields out of a line, and extracting every occurrence from a block of text.
Example 1: Email address validation
A single-line regex that checks whether a string looks like a reasonable email address. Useful as a pre-flight check before sending to a mail API.
Input
pattern: ^[\w.+-]+@[\w-]+\.[\w.-]+$
flags: (none)
test: alice.smith+work@example.co.kr
Output
Match 1:
value: "alice.smith+work@example.co.kr"
index: 0–30
groups: none
Example 2: Parse a structured log line
Named capture groups pull the timestamp, level, and message out of a standard application log entry in one pass.
Input
pattern: ^\[(?<ts>[^\]]+)\]\s+(?<level>\w+)\s+(?<msg>.+)$
flags: m
test: [2026-04-23T10:15:32Z] ERROR payment gateway timeout
Output
Match 1:
ts: "2026-04-23T10:15:32Z"
level: "ERROR"
msg: "payment gateway timeout"
Example 3: Extract every URL in a block of text
The global flag makes the engine keep matching until the string ends, so every link in a paragraph shows up in the match list.
Input
pattern: https?:\/\/[\w.\-]+(?:\/[^\s]*)?
flags: g
test: see https://example.com and http://docs.example.com/path?a=1 for details
Output
Match 1: "https://example.com" index: 4–23
Match 2: "http://docs.example.com/path?a=1" index: 28–60
Target language details
Version assumptions and style choices baked into the generated output. If your runtime is older, you may need to adjust syntax (e.g. drop optional chaining, use `var` instead of `const`).
| Language | Version | Output style |
|---|
| Regular Expressions | ECMAScript flavor (JavaScript) | Supports g / i / m / s / u / y flags; lookbehinds require ES2018+. |
| JavaScript | ES2017+; works in all evergreen browsers and Node 16+ | Functional + async; generated output uses fetch / async-await. |
Pattern cheat sheet
A few patterns cover most validation work. Copy any of these into the editor, add anchors as needed, and tweak against your samples.
| Target | Pattern | Notes |
|---|
| Email | ^[\w.+-]+@[\w-]+\.[\w.-]+$ | Pragmatic, not RFC 5322 |
| URL | https?:\/\/[\w.\-]+(?:\/[^\s]*)? | Use g flag for multiple |
| IPv4 address | \b(?:\d{1,3}\.){3}\d{1,3}\b | Matches structure, not validity (allows 999.999.999.999) |
| UUID v4 | [0-9a-f]{8}-[0-9a-f]{4}-4[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12} | Use i for upper-case hex |
| ISO date | \d{4}-\d{2}-\d{2} | Anchor with ^…$ for strict validation |
| Hex color | #([0-9a-fA-F]{3}){1,2}\b | Matches both #abc and #aabbcc |
Greedy vs lazy quantifiers
.*matches as much as possible before backtracking — the default, “greedy” behavior. .*?matches as little as possible, extending only when the rest of the pattern fails — “lazy”. The same distinction applies to + vs +? and {n,m} vs {n,m}?.
Classic example: parsing <b>one</b> <b>two</b> with <b>.*</b> matches the whole string (greedy ate past the first closing tag), while <b>.*?</b> correctly captures one tag at a time. When in doubt, reach for lazy first.
Lookahead and lookbehind
foo(?=bar) — positive lookahead: match foo only when immediately followed by bar. The bar is not consumed.foo(?!bar) — negative lookahead: match foo only when not followed by bar.(?<=$)\d+ — positive lookbehind: match digits only when preceded by $.(?<!\\\\)n — negative lookbehind: match n only whennot preceded by a backslash (so it doesn't match \n).
Lookarounds are zero-width: they assert position without consuming characters, which makes them ideal for “match X only when surrounded by Y” rules.
PCRE vs JavaScript vs Python regex
| Feature | JavaScript (this tool) | Python re | PCRE (PHP, etc.) |
|---|
| Lookbehind | Variable-width (modern) | Fixed-width only | Variable-width |
| Named groups | (?<name>...) | (?P<name>...) | Both syntaxes |
| Atomic groups | Not supported | 3.11+ only | (?>...) |
| Possessive quantifiers | Not supported | Not supported | .*+, .++ |
| Unicode property escapes | \p{L} with u flag | \p{L} with regex module | \p{L} with /u |
| Backslash in char class | [\\] | [\\] or r"[\\\\]" | [\\] |
Catastrophic backtracking
Patterns like (a+)+b against the string aaaaaaaaaaaaaaaaX can take exponential time as the engine tries every possible grouping of consecutiveas before giving up. The browser's regex engine has no built-in timeout — runaway patterns will hang the tab. Three defenses:
- Avoid nested quantifiers that can match the same characters multiple ways (
(a+)+, (.*)*, (a|a)*). - Anchor with
^ and $ when validating whole strings — the engine can fail faster. - Replace open-ended
.* with a narrower character class ([^"]* instead of .* when extracting quoted text).
Key Features
- Live highlighting — every match is colored inside the test string as you edit the pattern.
- Full flag support — g, i, m, s, and u cover global, case-insensitive, multiline, dotAll, and Unicode modes.
- Named and numbered capture groups are listed with values, so you can see what each parenthesis pulled out.
- Start and end indices are displayed per match, making it easy to slice the original string downstream.
- Invalid patterns surface a clear JavaScript error (unterminated group, unknown flag, etc.) instead of silently matching nothing.
- Runs entirely client-side — patterns and test data stay in your browser.
Frequently Asked Questions
Which regex flavor does the tester use?
It uses the browser's native ECMAScript RegExp engine. Patterns written here will behave identically in JavaScript and TypeScript. PCRE-only features such as possessive quantifiers and conditional patterns are not available.
Are lookahead and lookbehind supported?
Yes. Positive and negative lookahead (?=...) (?!...) work everywhere, and lookbehind (?<=...) (?<!...) works in all current Chromium, Firefox, and Safari releases.
Why does my pattern match nothing even though it looks right?
The most common causes are a missing global flag (only the first match shows up), an unescaped forward slash inside a URL, or a greedy quantifier that consumes past the intended boundary. Toggle the g flag and shrink the quantifier with*? or +? to see if the behavior changes.
Can I use named capture groups?
Yes. Use the (?<name>...) syntax. Named groups appear in the match details alongside the default numbered groups, and you can reference them downstream with result.groups.name.
Does the tester handle Unicode properties like \p{Letter}?
Yes, once the u flag is enabled. Without the flag, property escapes are treated as literal text. Flip on u whenever you need to match characters outside the basic Latin range, including CJK scripts and emoji.