Regex Tester — JavaScript regular expressions
Build a regular expression and see it match (or fail) against your test string in real time. Capture groups, flags and a replace preview are all live; nothing leaves your browser.
Build a regular expression and see it match (or fail) against your test string in real time. Capture groups, flags and a replace preview are all live; nothing leaves your browser.
Reach out at <<hello@example.com>> or <<support@utility.test>> for help.
A regular expression (regex) is a small language for describing patterns in text. With a few characters you can extract emails from a paragraph, validate that a postcode follows a country's format, or rewrite every snake_case identifier in a file into camelCase. Modern JavaScript engines compile a regex once and then run it as fast as a tight loop.
This tester uses the platform's native RegExp implementation, so anything that works here also works at runtime in Node, Deno, Bun and every modern browser. The flags g, i, m, s, u and y change matching semantics; capture groups (the parentheses in the pattern) collect substrings you can reference in the replacement as $1, $2 etc.
JavaScript / ECMAScript regex (the same engine your code will run against). That means lookbehinds, named groups (?<name>…) and Unicode property escapes \p{…} all work. PCRE-only features like recursive patterns are not supported.
Escape it with a backslash: \., \?, \(, \). Inside a character class [.] the dot is already literal so [.?] matches a literal dot or question mark.
.* is greedy — it grabs as much as possible then backtracks. .*? is lazy — it grabs as little as possible then expands. Lazy is what you want for matching content between markers; greedy is what you want for matching whole lines.
If you use the global (g) flag and reuse the same RegExp object, lastIndex advances after each exec(). Reset it with regex.lastIndex = 0, or build a new RegExp on each call. This tester resets it for you between renders.
No. Everything runs in your browser via the native RegExp engine. Your inputs never touch our servers, so the tester is safe to use even with sensitive data like a log line containing tokens.
Where reaching for a regex pays off in seconds.
An email, a postcode, a phone number — a tight regex is faster to write than a parser and is fine when you just need a sanity check before sending data downstream.
Pull request IDs, IPs or status codes out of a stream of log lines without parsing JSON. Capture groups give you the fields directly.
Rename a function, change a quote style, or update a deprecated API call across a whole codebase by piping ripgrep into sed — both speak regex.
Most editors (VS Code, JetBrains, Vim) ship a regex search-and-replace. Test the pattern here first to avoid mass-corrupting a file.
Habits that keep regexes maintainable.
If a value should occupy a whole field, anchor with ^ at the start and $ at the end. Without anchors, /\d+/ matches inside 'abc123def' too — usually not what you want for validation.
[abc] is faster and clearer than (a|b|c). Use alternation only when the alternatives are multi-character.
JavaScript does not have the verbose flag, but you can build the pattern from a string literal split across lines and join it. For complex patterns, that is a far better readability win than one mega-line.
Don't try to parse HTML, JSON or anything with nested structure. Use a real parser (DOMParser, JSON.parse, an AST). Regex shines on flat textual patterns, not tree-structured data.