Regex Tester Online — Test JavaScript Regular Expressions Live
Test a regular expression against sample text with live match highlighting, capture groups and replace preview. Free, in your browser.
Contact us at hello@pine-and-birch.com or sales@example.org. Site: https://www.pine-and-birch.com/tools — call (416) 555-0199. Launched 2026-09-08, colours #071e93 and #fff, server 10.0.0.12.
| # | Match | Index | Groups |
|---|---|---|---|
| 1 | hello@pine-and-birch.com | 14 | — |
| 2 | sales@example.org | 42 | — |
Runs entirely in your browser. Nothing you enter is sent to us or stored. Validating input, parsing logs or cleaning data at scale is usually a job for code, not a regex in a text box. We build that kind of tooling.
Found a problem, or something that could be better? We read every message and we fix things quickly.
This free regex tester runs JavaScript regular expressions against your sample text in the browser and highlights every match as you type. Capture groups, named groups and the match index are listed for each hit, and a replace mode previews substitutions with $1 and $<name> exactly as String.replace will do them.
The engine is your browser's own, so results match Node.js, React, Deno and every web framework exactly; they are close to, but not identical with, PCRE (PHP, Python's re, grep -P). The differences that matter most, lookbehind support, possessive quantifiers and \A anchors, are noted below so a pattern that works here does not surprise you elsewhere.
How to use
- Type a pattern without the surrounding slashes, or click a preset (email, URL, phone, date, IPv4, hex colour) to start from something known-good.
- Tick the flags you need. g finds all matches rather than the first; i ignores case; m makes ^ and $ match line starts and ends.
- Paste your test text. Matches highlight immediately and the table lists each one with its capture groups.
- Open Replace to preview a substitution. Use $1 for numbered groups, $<name> for named groups and $& for the whole match.
- Copy the pattern as /pattern/flags for JavaScript literals, or as new RegExp() when the pattern comes from a string.
Frequently asked questions
Which regex flavour does this use?
ECMAScript (JavaScript), because the browser evaluates the pattern directly. That is what Node.js, front-end code and JSON schema patterns use. Python, Java, Go, PHP and grep have their own engines that agree on the basics and differ at the edges; test in the target language before shipping anything unusual.
Why does my pattern only find the first match?
The g (global) flag is off. Without it, JavaScript stops at the first match, which is correct for a validation check and wrong for extraction. Turn on g to list every match.
How do I match across multiple lines?
Two different flags do two different things. m (multiline) makes ^ and $ match at each line start and end. s (dotAll) makes . match newline characters too. For “anything including line breaks” without s, the idiom is [\s\S]*.
What is a named capture group?
(?<year>\d{4}) captures four digits under the name year, so you can read match.groups.year instead of counting parentheses, and refer to it as $<year> in a replacement. Named groups make long patterns readable and survive edits that add or remove other groups.
Can a regex be slow or dangerous?
Yes. Patterns with nested quantifiers such as (a+)+ or overlapping alternations can take exponential time on some inputs (catastrophic backtracking, a real denial-of-service vector). If a pattern makes this page freeze, that is the same thing that would freeze your server. Prefer specific character classes over .* and avoid nesting quantifiers.
Should I validate email addresses with a regex?
Only loosely. The preset here matches the common shape and rejects obvious typos, which is all a form should do. A fully RFC 5322-correct pattern is thousands of characters long and still cannot tell you whether the mailbox exists. Check the shape, then send a confirmation email.
A short regex cheat sheet
• . any character except newline · \d digit · \w word character · \s whitespace · \b word boundary
• * zero or more · + one or more · ? optional · {n,m} between n and m times · add ? after any of these to make it lazy
• [abc] any of · [^abc] none of · [a-z] range · (x|y) alternation · (?:x) non-capturing group
• ^ start · $ end · (?=x) lookahead · (?!x) negative lookahead · (?<=x) lookbehind (JavaScript and PCRE, not all engines)
• Escape special characters with a backslash: \. \? \( \[ \\
JavaScript vs PCRE: the differences you will actually hit
JavaScript has no possessive quantifiers (a++), no atomic groups, no \A or \Z anchors (use ^ and $ without the m flag), and no inline modifiers like (?i). It does support lookbehind, named groups and Unicode property escapes such as \p{L} when the u flag is on. Python's re additionally lacks \p{...} without the regex package, and Go's RE2 has no lookaround at all. If a pattern must run in several languages, stay inside the common subset: character classes, simple groups, anchors and greedy or lazy quantifiers.
Related free tools
- JSON Formatter — Pretty-print, minify and validate JSON, with parse errors located by line and column. In your browser, no upload.
- Base64 Encoder / Decoder — Encode text or files to Base64 and decode back, with correct UTF-8 handling and data-URL output. Nothing leaves your browser.
- Word Counter — Count words, characters, sentences and reading time, and see keyword density and your most-used phrases as you type.