https://www.webdevawards.org/tools/regex-tester"https""www.webdevawards.org""/tools/regex-tester""https""www.webdevawards.org""/tools/regex-tester"https://www.webdevawards.org/resources/aphex-creations"https""www.webdevawards.org""/resources/aphex-creations""https""www.webdevawards.org""/resources/aphex-creations"http://projects.aphexcreations.net/rejax/"http""projects.aphexcreations.net""/rejax/""http""projects.aphexcreations.net""/rejax/"How to Use the JavaScript Regex Tester
This utility evaluates regular expressions directly against your browser’s native JavaScript RegExp runtime, ensuring that every pattern behaves identically to production Node.js, Cloudflare Workers, Deno, and modern browser environments.
- Enter a Regular Expression Pattern: Type your expression between the forward slashes (
/.../) without enclosing delimiters, or click one of the Pattern Presets above to load a working example. - Configure Expression Flags: Toggle flags such as
g(global),i(case-insensitive),m(multiline),s(dotAll),u(Unicode), ord(capture group indices) using the interactive flag bar. - Inspect Matches & Capture Groups: Paste your multiline sample text. Matched substrings are highlighted immediately, and the Matched Groups & Positions panel displays the exact character start/end indices, line/column numbers, numbered sub-groups (
$1,$2), and named capture groups (match.groups). - Test Replacements & Export Code: Switch to the String.replace() Preview tab to test substitution tokens (
$&,$1,$<name>), or use the top toolbar buttons to copy the regex literal, ready-to-run JavaScript snippet, or structured JSON match array.
Need a deeper syntax walkthrough? Read our companion JavaScript Regex Guide: Syntax, Examples & Patterns.
Common JavaScript Regex Examples
Below are battle-tested regular expressions frequently used in frontend validation, server-side routing, and log parsing. You can load most of these directly using the preset buttons inside the tester above:
| Use Case | Pattern & Flags | Notes |
|---|---|---|
| Standard Email Format | /\b([a-zA-Z0-9._%+-]+)@([a-zA-Z0-9.-]+\.[a-zA-Z]{2,})\b/g | Captures username in $1 and domain in $2. |
| HTTPS/HTTP URL with Named Groups | /(?<protocol>https?):\/\/(?<host>[a-z0-9.-]+)(?<path>\/[^\s]*)?/gi | Populates match.groups.protocol, host, and path. |
| ISO 8601 Date (YYYY-MM-DD) | /\b(?<year>\d{4})-(?<month>0[1-9]|1[0-2])-(?<day>0[1-9]|[12]\d|3[01])\b/g | Restricts months to 01–12 and days to 01–31. |
| IPv4 Address | /\b(?:(?:25[0-5]|2[0-4]\d|[01]?\d\d?)\.){3}(?:25[0-5]|2[0-4]\d|[01]?\d\d?)\b/g | Uses non-capturing groups (?:...) to validate 0–255 octets. |
| First File in a Multi-Part RAR Archive | /^(?<basename>.+?)(?:\.part0*1\.rar|(?<!\.part\d+)\.rar)$/gim | Uses negative lookbehind (?<!\.part\d+) so standalone .rar and .part01.rar match while .part02.rar is ignored. |
| Semantic Version (SemVer 2.0) | /^v?(?<major>0|[1-9]\d*)\.(?<minor>0|[1-9]\d*)\.(?<patch>0|[1-9]\d*)(?:-(?<prerelease>[0-9A-Za-z.-]+))?(?:\+(?<build>[0-9A-Za-z.-]+))?$/gm | Parses major, minor, patch, pre-release, and build metadata. |
Supported Regular Expression Flags
Modern JavaScript engines support eight regular expression flags that modify how patterns are compiled and executed:
Finds all matches across the input string rather than returning after the first match. Required when calling String.prototype.matchAll().
Makes pattern matching case-insensitive (/[a-z]/i matches both a–z and A–Z).
Changes ^ and $ so they match the beginning and end of each line (delimited by \n or \r) instead of only the start and end of the entire string.
Allows the dot metacharacter (.) to match line terminators (\n, \r, \u2028, \u2029).
Treats astral Unicode surrogates as complete code points and unlocks Unicode property escapes such as \p{Letter} and \p{Emoji}.
Attaches an indices array to exec() results containing the exact [start, end] character offsets for every captured sub-group.
Anchors matching strictly to the current regex.lastIndex position without scanning forward—ideal for lexical tokenisers.
Upgrades u mode with set intersection (&&), subtraction (--), and multi-character string properties inside character classes.
Capturing Groups, Named Groups & Lookarounds
Parentheses in JavaScript regular expressions serve two distinct purposes: grouping quantifiers/alternations and extracting matched sub-strings for inspection or replacement.
const logLine = "2026-10-12T22:45:10Z [ERROR] Worker timeout after 1500ms";
const pattern = /^(?<timestamp>\S+) \[(?<level>INFO|WARN|ERROR)\] (?<message>.+?) \((?<ms>\d+)ms\)|^(?<ts>\S+) \[(?<lvl>INFO|WARN|ERROR)\] (?<msg>.+)$/;
const urlPattern = /(?<protocol>https?):\/\/(?<host>[^/]+)(?<path>\/.*)?/d;
const match = urlPattern.exec("https://www.webdevawards.org/tools/regex-tester");
if (match) {
console.log(match[0]); // Full match
console.log(match[1]); // "https" (Numbered Group $1)
console.log(match.groups.host); // "www.webdevawards.org" (Named Group)
console.log(match.indices.groups); // { protocol: [0, 5], host: [8, 28], path: [28, 47] }
}- Capturing Group
(pattern): Captures the matched substring into numbered slots (match[1],match[2]) and allows backreferences inside the pattern via\1,\2. - Named Capturing Group
(?<name>pattern): Assigns a semantic identifier accessible onmatch.groups.name, backreferenced via\k<name>, and referenced inreplace()via$<name>. - Non-Capturing Group
(?:pattern): Groups tokens for quantifiers or alternation (e.g.,(?:http|https)) without allocating memory in the capture array. - Lookahead & Lookbehind Assertions: Zero-width assertions that verify surrounding text without consuming characters: positive lookahead
(?=...), negative lookahead(?!...), positive lookbehind(?<=...), and negative lookbehind(?<!...).
The Historical REJAX Connection
In February 2007, software developer Brendon Crawford launched REJAX at http://www.projects.aphexcreations.net/rejax/ (and projects.aphexcreations.net/rejax) under the Aphex Creations banner. Described across developer bookmarking communities as “rejax - easiest regular expression tester. ever.” and “rejax - coolest regular expression tester. ever.”, REJAX was one of the first developer tools to demonstrate that complex regular expression debugging could run entirely inside the browser DOM without server-side round-trips.
Over nearly two decades, REJAX was cited by Ajaxian, phpspot, KickJava, Xmarks, Diigo JavaScript Online Tools, and the Gouvernement du Québec WebMaestro portal (as a reference testeur d’expressions régulières). When the historical Aphex Creations domain was retired and migrated into the Web Dev Awards developer resources archive, preserving a fast, zero-advertisement, interactive JavaScript regular expression tester at this destination was our top priority so every historical link continues to serve working code.
JavaScript Regular Expression FAQ
- How does this JavaScript regex tester evaluate patterns?
- The tester uses your browser's native ECMAScript RegExp engine in real time. No test strings or regular expressions are transmitted to an external server, guaranteeing instant zero-latency evaluation and complete privacy for sensitive log files or payloads.
- Why does my pattern only return one match instead of all occurrences?
- In JavaScript, RegExp.prototype.exec() and String.prototype.match() stop after the first match unless the global (g) flag is enabled. Toggle the 'g' flag in the toolbar above to iterate through every match in your multiline sample text.
- What is the difference between numbered capture groups and named capture groups?
- Numbered capture groups use standard parentheses like (\d{4}) and are accessed by index (match[1], $1). Named capture groups use the (?<year>\d{4}) syntax introduced in ES2018 and populate the match.groups.year object property as well as $<year> in replacement strings.
- What happened to the original REJAX regular expression tester?
- REJAX (originally hosted at projects.aphexcreations.net/rejax/ by Brendon Crawford at Aphex Creations in 2007) was one of the web's earliest live browser-based JavaScript regular expression testers. Web Dev Awards built and maintains this modern, dependency-free JavaScript Regex Tester as a permanent functional replacement for historical REJAX bookmarks.
- How do I match across multiple lines including newline characters?
- Enable the 'm' (multiline) flag if you want ^ and $ anchors to match the start and end of individual lines rather than the entire string. Enable the 's' (dotAll) flag if you want the dot metacharacter (.) to match newline characters (\n and \r).