Regex Tester

Write a pattern, paste a string. Matches highlight instantly.

//g

How the Regex Tester Works

Type a regular expression pattern in the input field and choose your flags (g for global, i for case-insensitive, m for multiline, s for dotAll, u for unicode, y for sticky). As you type, every match in the test string is highlighted with a colored span. The match list below shows each match's index position, full match text, and any captured groups.

Switch to Replace mode to preview the result of a substitution — use $1, $2, etc. to reference captured groups in the replacement string. The common patterns library provides one-click presets for email, URL, phone, IPv4, IPv6, UUID v4, hex color, credit card, ISO 8601 date, and semver.

References

This tool implements ECMAScript regular expressions as defined in ECMAScript 2026 Language Specification — Section 22.2: RegExp (Regular Expression) Objects (tc39.es/ecma262). The JavaScript RegExp engine runs entirely in your browser — no server call is made.

Secondary reference: MDN Web Docs — Regular Expressions Guide.

What's here — and what's not

Live match highlighting with per-match color coding, a replace preview, six flags, a common pattern library, and a collapsible cheatsheet covering anchors, quantifiers, character classes, groups, and lookarounds.

What isn't here: PCRE-specific features (recursive groups, conditionals, possessive quantifiers), Python re syntax, .NET lookbehind extensions, or multi-engine comparison. This tool runs pure ECMAScript RegExp — what every browser already ships. No PCRE, no Python, no exotic extensions.

Frequently Asked Questions

Which regex engine does this use?
This tester uses the ECMAScript RegExp engine built into your browser's JavaScript runtime. It is fully compliant with the ECMAScript 2026 specification (Section 22.2). If a pattern works here, it will work in any modern JavaScript runtime (Node.js, Deno, browser).
What does the g (global) flag do?
The g flag makes the regex find all matches, not just the first one. Without g, the engine stops after the first match. Most use cases need g — that's why it's enabled by default in this tool.
How do captured groups work in replace mode?
Wrap part of your pattern in parentheses to create a capturing group — e.g. (\d+). In the replacement string, reference it with $1, $2, etc. For example, pattern (\w+)\s(\w+) with replacement $2 $1 swaps two words.
Is this compatible with PCRE (PHP, Python, Ruby)?
Partially. ECMAScript and PCRE share most syntax (character classes, quantifiers, basic lookarounds). However PCRE supports recursive groups (?R), possessive quantifiers ++, conditional patterns (?(cond)yes|no), and atomic groups (?>). These are not supported here. Python's re module also has differences. Test here for JavaScript/Node.js targets; for other runtimes, verify separately.
Where is the regex spec documented?
The authoritative source is the ECMAScript 2026 Language Specification, Section 22.2 — RegExp (Regular Expression) Objects, published by TC39 at tc39.es/ecma262. MDN Web Docs provides a practical reference guide at developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Regular_expressions.