About the Regex Tester
The Regex Tester compiles your pattern against a test string in real time and highlights every match inline, with a side panel listing numbered and named capture groups, match counts, and per-match positions. All standard JavaScript regex flags are toggleable — g (global), i (case-insensitive), m (multiline anchors), s (dotAll), u (Unicode), y (sticky) — with live re-evaluation on every keystroke.
It is built for developers debugging a pattern that “works in Python but not JS,” data engineers prototyping a normalization rule before pushing it to production, QA writing assertion patterns, and security teams hardening input validation. A built-in pattern library covers the routine targets (email, URL, IPv4, IPv6, UUID, credit-card, phone, ISO date) so you adapt rather than write from scratch.
Compilation and matching happen entirely in JavaScript on your device. Pattern, test string, and capture history never leave your browser. The page makes no network call after first load. Regex inputs frequently contain credential formats, customer-data shapes, internal schema, or proprietary identifier patterns — categorically the kind of input that should not be uploaded to a third-party service.
Regex engines are not portable. JavaScript’s RegExp diverges from PCRE (PHP, R), Python re, Go regexp (RE2 — no backreferences, no lookbehind), and POSIX BRE/ERE in meaningful ways — lookbehind support, named-group syntax, Unicode property escapes, and catastrophic-backtracking behavior all differ. Test in the runtime that will execute the pattern. And never parse HTML with regex — use a DOM parser, every time.
RegExp · ES2022How to Use the Regex Tester
Type or paste your regular expression in the Pattern field, then
paste the text you want to test against in the Test String area.
Matches are highlighted instantly. Toggle flags using the chips below the pattern:
g (global — find all matches), i (case-insensitive),
m (multiline — ^ and $ match line
boundaries), and s (dotAll — . matches newlines).
Understanding Regex Flags
Flags modify how the regex engine interprets your pattern. The global
flag is the most commonly needed — without it, the engine stops after the first
match. Case-insensitive makes /hello/i match
“Hello,” “HELLO,” and “hElLo.” Multiline
is essential when your test string contains line breaks and you want ^
and $ to anchor to each line, not just the entire string. DotAll
lets the dot metacharacter match newline characters, useful for patterns that span
multiple lines.
Capture Groups Explained
Parentheses in a regex create capture groups that extract specific
parts of a match. For example, (\d{3})-(\d{4}) matching
“555-1234” produces two groups: “555” and “1234.”
Named groups use the syntax (?<name>...) and make your regex
self-documenting. The match table shows all groups for every match, and subscribers
can see named groups in a dedicated panel.
Common Regex Patterns
The built-in pattern library includes ready-to-use expressions for everyday tasks: email validation, URL matching, phone numbers, IP addresses, dates, and more. Click any pattern to load it into the tester immediately. These patterns are production-tested starting points — you may need to adjust them for edge cases specific to your data format.
Reading the Pattern Explanation
Regular expressions can look cryptic even to experienced developers. The explanation
mode (available to subscribers) breaks your pattern into individual tokens and
describes each one in plain English. For instance, \b[A-Z][a-z]+\b
becomes: “word boundary, one uppercase letter A–Z, one or more lowercase
letters a–z, word boundary.” This makes it much easier to debug complex
patterns and understand regex you didn’t write yourself.
Tips for Writing Better Regex
Start simple and add complexity incrementally — test after every change. Use
character classes ([abc]) instead of alternation (a|b|c)
when possible; they’re faster. Prefer non-greedy quantifiers (*?,
+?) when you want the shortest possible match. Anchor your patterns
with ^ and $ when you need to match the entire string.
And always test with edge cases: empty strings, special characters, and inputs
longer than you expect.
Regex in Different Programming Languages
Most languages implement regex using PCRE (Perl-Compatible Regular Expressions) or a
close derivative, but there are meaningful differences that can break a pattern when you
move it between environments. Python’s re module supports verbose
mode (re.VERBOSE) for adding inline comments and whitespace, which is
invaluable for maintaining complex patterns. JavaScript historically lacked lookbehind
support in older engines, though modern V8 and SpiderMonkey have added it — if
you target older browsers, lookbehind assertions may not be safe to use. Go’s
standard regexp package uses RE2 semantics, which intentionally excludes
backreferences and some lookarounds to guarantee linear-time matching and prevent
catastrophic backtracking. Java and PHP can also diverge in how \s
handles Unicode whitespace characters. The safest approach is always to test your
pattern in the actual runtime environment of your target application, not just in a
browser-based tester.
Regex is often the right tool for scanning structured text, but for hierarchical data formats you will want purpose-built parsers — the JSON Formatter & Validator is a natural complement when you are extracting fields from JSON payloads. If you are working with encoded strings that need to be decoded before matching, the Base64 & Encoding Toolkit can handle that step first.
Frequently Asked Questions
What is the difference between greedy and lazy quantifiers?
Greedy quantifiers like * and + match as much as possible, while lazy variants like *? and +? match as little as possible. For example, <.*> greedy matches the entire <b>hi</b>, while <.*?> lazy matches just <b>. Use lazy when parsing paired delimiters like HTML tags.
Why does my regex work in Python but not JavaScript?
Different engines support different features. JavaScript historically lacked lookbehind until ES2018 and still does not support certain Unicode property escapes without the u flag. PCRE, Python re, and Go regexp each have their own quirks, so always test in the environment that will run the regex.
Can I use regex to parse HTML?
Not reliably. HTML is not a regular language, so nested tags and attributes break any fixed regex. Use a parser like DOMParser in the browser, Cheerio in Node, or Beautiful Soup in Python. Regex is fine only for simple scraping of well-known patterns.
What does the g flag actually do?
The g (global) flag tells the engine to find every match instead of stopping at the first. In JavaScript it also causes RegExp.prototype.exec and String.prototype.matchAll to iterate, and it makes the regex stateful via its lastIndex property, which can surprise you if you reuse the same object.
How do I match Unicode characters like emoji or accented letters?
Enable the u flag and use Unicode property escapes such as \p{Letter} or \p{Emoji}. Without u, the dot metacharacter sees surrogate pairs as two separate code units, so emoji and some CJK characters do not match correctly.