Email address
Practical validation for common addresses, not the full RFC grammar.
\b[A-Za-z0-9._%+-]+@[A-Za-z0-9.-]+\.[A-Za-z]{2,}\b Test JavaScript regular expressions with live match highlighting, capture groups, replacements, token explanations, positive and negative test cases, match exports and shareable URL state. Catastrophic patterns run in an isolated worker and are stopped after two seconds.
Write the pattern without surrounding slashes. Results update as you type.
JavaScript replacement syntax supports numbered and named capture references.
High-confidence token explanations generated locally. Complex or invalid syntax is still validated by the JavaScript engine.
One case per line. Prefix with + when it should match or - when it should not. Lines without a prefix are expected to match. One separator space after the prefix is ignored; any other whitespace is part of the case.
Full match, position, length and capture group values.
Matches will appear here.
| # | Match | Position | Length | Capture groups |
|---|
Validate strings that should match and strings that should not.
| # | Case | Expected | Actual | Result |
|---|
The exact output JavaScript produces for the current pattern, flags and replacement string.
Start with a working pattern and adapt it. These examples are intentionally practical: strict enough for everyday extraction and validation, small enough to understand before trusting them in production.
Practical validation for common addresses, not the full RFC grammar.
\b[A-Za-z0-9._%+-]+@[A-Za-z0-9.-]+\.[A-Za-z]{2,}\b Matches ordinary http and HTTPS URLs in prose or logs.
\bhttps?:\/\/[^\s<>"']+ Validates octets from 0 to 255 instead of accepting 999.999.999.999.
\b(?:(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)\.){3}(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)\b Covers YYYY-MM-DD and common ISO 8601 timestamp forms.
\b\d{4}-\d{2}-\d{2}(?:[T ]\d{2}:\d{2}(?::\d{2}(?:\.\d{1,3})?)?(?:Z|[+-]\d{2}:?\d{2})?)?\b Accepts #rgb, #rrggbb and #rrggbbaa.
#(?:[0-9a-fA-F]{8}|[0-9a-fA-F]{6}|[0-9a-fA-F]{3})\b Full semver shape with optional prerelease and build metadata groups.
\b(0|[1-9]\d*)\.(0|[1-9]\d*)\.(0|[1-9]\d*)(?:-((?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*)(?:\.(?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*))*))?(?:\+([0-9a-zA-Z-]+(?:\.[0-9a-zA-Z-]+)*))?\b Lowercase words separated by single hyphens.
\b[a-z0-9]+(?:-[a-z0-9]+)*\b A loose E.164-style matcher for quick extraction, not carrier validation.
\+(?:\d[\s-]?){7,14}\d The small set of syntax that covers most day-to-day validation, extraction and replacement work.
| Category | Syntax | Meaning |
|---|---|---|
| Character classes | . | Any character except line breaks (or all characters with s) |
| Character classes | \d \D | Digit / not a digit |
| Character classes | \w \W | Word character [A-Za-z0-9_] / negated |
| Character classes | \s \S | Whitespace / non-whitespace |
| Character classes | [abc] [^abc] | One listed character / one character not listed |
| Quantifiers | * + ? | Zero or more / one or more / optional |
| Quantifiers | {n} {n,} {n,m} | Exact, minimum, or bounded repetition |
| Quantifiers | *? +? | Lazy repetition: stop at the first acceptable end |
| Anchors | ^ $ | Start/end of input, or line boundaries with m |
| Anchors | \b \B | Word boundary / not a word boundary |
| Groups | (...) | Numbered capture group, available as $1 in replacement |
| Groups | (?:...) | Non-capturing group |
| Groups | (?<name>...) | Named capture group, available as $<name> |
| Groups | \1 | Backreference to a previous numbered group |
| Lookaround | (?=...) (?!...) | Positive / negative lookahead |
| Lookaround | (?<=...) (?<!...) | Positive / negative lookbehind |
| Flags | g i m | Global, case-insensitive, multiline |
| Flags | s u y d | dotAll, Unicode, sticky, capture indices |
JavaScript regexes run on the main thread in most tools. When a pattern backtracks catastrophically,
the browser cannot paint, scroll or even close the tab comfortably. The usual example is
(a+)+$
against thirty or forty a characters followed by
!. The inner and outer quantifiers can split the same
run of characters in exponentially many ways, and the engine tries them before admitting failure.
This tester moves execution into a disposable Web Worker. If nothing comes back within two seconds, the worker is terminated and you get a warning instead of a frozen page. It also scans the pattern locally for high-confidence nested-quantifier and overlapping-alternation risks before execution. Those warnings are conservative heuristics, not proof, but they are a strong signal to rewrite nested quantifiers, tighten character classes or anchor the input more precisely.
Regex syntax is not one universal language. This page executes the pattern with the browser's native JavaScript engine. That is useful when the target runtime is JavaScript or TypeScript, and misleading when you need exact PCRE, Python or Java behavior.
| Named groups | (?<name>...) | Supported in modern JavaScript |
|---|---|---|
| Lookbehind | (?<=...) and (?<!...) | Supported in modern browsers |
| Atomic groups | (?>...) | Not supported; use careful quantifiers instead |
| Possessive quantifiers | a++ a*+ | Not supported |
| Unicode properties | \p{L} | Requires the u flag |
| Replacement references | $1 and $<name> | Supported by String.replace() |
A tester answers “does this pattern match?”. Production code also needs escaping, validation boundaries, input size limits and language-specific replacement behavior. These resources cover that next step.
Regex input often contains production logs, customer data, tokens or internal hostnames. This tool does not send the pattern, test string, test cases or loaded files anywhere; file loading uses the browser's local FileReader. The only persistence is the URL hash you choose to copy or bookmark; clearing the URL clears the shared state.
Use $1 and $2 for numbered captures,
$<name> for named captures, and
$& for the whole match. Escape a literal dollar sign as
$$. The preview uses JavaScript's native
String.replace(), so what you see is what the runtime will do.
It executes the JavaScript regular expression flavor because that is the engine built into your browser. Modern JavaScript supports lookahead and lookbehind, named capture groups, Unicode mode and the dotAll flag, but it does not support PCRE features such as atomic groups or possessive quantifiers. If a pattern behaves differently in Python, Java or PCRE, check the syntax before copying it across languages.
Some patterns enter catastrophic backtracking: the engine tries an exponential number of ways to divide the input among nested quantifiers. A classic example is (a+)+$ against a long string of a characters followed by a character that prevents the final match. This tester runs the regex in a Web Worker and terminates it after two seconds instead of letting the tab freeze.
$1 inserts the first numbered capture group, while $<name> inserts a named capture group such as (?<word>\w+). Numbered references are compact; named references are easier to read when a pattern has several groups. JavaScript supports both forms in String.replace().
No. Matching and replacement run locally in your browser. The tool makes no network requests and stores nothing on a server. State is encoded in the URL hash only so you can bookmark or share the exact same session.
Patterns such as a*, .*? or an optional group can legitimately match an empty string. JavaScript advances the search position after each empty global match to avoid an infinite loop. The tester follows the same rule and displays those matches as empty strings.
Regex flavors share a core syntax but differ in edge features and escaping rules. JavaScript does not support atomic groups, possessive quantifiers, \A or \z anchors, or PCRE branch reset groups. Python uses different flag names and replacement syntax. Validate the final pattern in the runtime that will execute it.