Regex Tester

Processed locally · Never leaves your browser

Test regular expressions with live highlighting, capture groups, named groups, and replace preview. JavaScript/ECMAScript syntax.

/
/g
Replace:
Test String
Highlighted Matches
Highlights will appear here…

Common Patterns

Click to load

Runs entirely in your browser — nothing is uploaded
Runs entirely in your browser. No uploads. Your files stay private.

What Is a Regex Tester?

A regex tester lets you write a regular expression, run it against sample text, and see exactly which substrings match. This tool builds the pattern using JavaScript's native RegExp constructor — the same engine that ships with V8 (Chrome, Node), JavaScriptCore (Safari), and SpiderMonkey (Firefox). That means the syntax, escape rules, and flag semantics here are the ECMAScript flavor: PCRE-style features like atomic groups and possessive quantifiers are not supported, but lookaheads, lookbehinds, named groups, and Unicode property escapes all work.
Highlighting and the match list are produced by repeatedly calling RegExp.prototype.exec on the test string. When the global flag is set, exec advances lastIndex on each call until no more matches are found. The tool always passes the g flag to its internal iteration even if you have not enabled it, so the highlight pass and the match list show every occurrence; your chosen flags still control case sensitivity, multiline anchors, dot-all behavior, and Unicode parsing.
All five common flags are exposed: g for global iteration, i for case-insensitive matching, m so that ^ and $ anchor at line boundaries instead of string boundaries, s (dot-all) so that . matches newline characters, and u to enable full Unicode mode including \p property escapes and surrogate-pair-aware matching. The y (sticky) flag is intentionally omitted because it complicates iterating from a stand-still UI; if you need it, paste your pattern into Node and step through manually.
The biggest pitfall in regex is catastrophic backtracking. Patterns like (a+)+$ or (.*)*x can take exponential time on inputs that almost match — a 30-character string might lock the page for minutes. JavaScript engines do not have a built-in regex timeout, so a runaway pattern entered in this UI can briefly freeze the tab. Use atomic-style rewrites (anchor your alternations, replace nested quantifiers with character classes) to avoid the problem; the tool's StatsBar will show whether your input is small enough to be safe.
Replacement uses String.prototype.replace under the hood. The replacement string supports the standard JavaScript escapes: $1 through $99 for numbered groups, $<name> for named groups, $& for the entire match, $` and $' for the text before and after, and $$ for a literal dollar sign. The preview pane updates as you type so you can confirm substitutions before running them on a real file.
The Common Patterns shelf loads tested-but-not-bulletproof starting points. The email pattern accepts most addresses but is far simpler than the official RFC 5322 grammar (which is famously almost impossible to express as a regex); the URL pattern handles common HTTPS shapes but not edge cases like punycode or URL fragments. Treat the presets as scaffolding to adapt, not as production validators.
Nothing leaves your browser. The pattern, flags, test string, and replacement are stored in component state and are never serialized or sent over the network. You can disconnect from the internet and the tool keeps working — RegExp is built into every modern JavaScript runtime.

Common Use Cases

01

Form input validation

Iterate on email, phone, postal code, or custom patterns and see immediately which inputs pass or fail.

02

Log file extraction

Build named-group patterns that pull timestamps, severity levels, and request IDs from server log lines.

03

Bulk find and replace

Preview a complex substitution with capture groups before applying it across a codebase or document.

04

Data scraping cleanup

Strip HTML noise, normalize whitespace, or extract IDs from semi-structured text dumps.

Frequently Asked Questions

ECMAScript (JavaScript). It supports named groups, lookbehind, Unicode property escapes with the u flag, and the standard quantifiers and character classes. PCRE-only features like atomic groups, recursion, and conditional patterns are not available.
g (global), i (case-insensitive), m (multiline anchors), s (dot-all so . matches newlines), and u (full Unicode parsing). The y/sticky flag is not exposed here because it conflicts with the highlight loop.
Yes. Each match displays its numbered groups ($1 onward) and any named groups defined with the (?<name>...) syntax. Both forms are usable in the replacement string as $1 or $<name>.
Type the replacement in the Replace field. Use $1, $2 for numbered groups, $<name> for named groups, $& for the entire match, and $$ to insert a literal dollar sign. The preview updates as you type.
It is almost certainly catastrophic backtracking. Patterns with nested quantifiers like (a+)+ or (.*)*x can take exponential time on inputs that nearly match. Anchor your alternations, avoid nested unbounded quantifiers, and prefer character classes.
Either enable the s (dot-all) flag so the dot matches newlines, or use a character class like [\s\S] which always matches any character including newlines and works in older engines that lack the s flag.
By default, ^ and $ anchor to the start and end of the entire string. Enable the m (multiline) flag to make them anchor at every line boundary, which is what most log-parsing tasks need.
Yes, with the u flag. That enables full Unicode mode and unlocks property escapes like \p{Letter}, \p{Emoji}, and proper handling of surrogate pairs. Without u, characters outside the basic multilingual plane behave unexpectedly.
Email syntax (RFC 5322) is far more permissive than the simplified pattern in the presets. Real validators accept addresses with dots, plus signs, quoted strings, and IDN domains. For production, check a library like email-validator instead of relying on a regex.
No. Pattern compilation and matching happen in your browser via the built-in RegExp constructor. Nothing is logged, stored, or transmitted.

Step-by-step guide

How to test a regex online

Walk through every step with screenshots, format-specific tips, and the platform-by-platform limits you need to know.

Advertisement