1. Interactive JavaScript Regex Tester & Match Inspector
The ToolMono Online Regex Tester is a browser-first regular expression evaluator, pattern debugger, and code generator. It compiles and evaluates regular expressions directly inside your browser memory using JavaScript's native ECMAScript RegExp engine, delivering real-time match highlighting, capture group indexing, flag adjustments, and multi-language code snippets.
2. How to Test Regular Expressions Online
Follow these five steps to test regex patterns, extract capture groups, preview text replacements, and generate clean application code:
3. JavaScript Regex Syntax & Token Cheat Sheet
Reference the tables below for standard regular expression tokens, character classes, anchors, quantifiers, groups, and lookarounds in ECMAScript:
Character Classes & Wildcards
| Token | Meaning / Description | Example Pattern | Matching Output |
|---|---|---|---|
| . | Any single character except newline (\n) unless 's' flag is active | c.t | cat, cut, c9t |
| \d | Any digit character [0-9] | \d3 | 123, 890 |
| \D | Any non-digit character [^0-9] | \D+ | abc, hello |
| \w | Word character [a-zA-Z0-9_] | \w+ | user_name123 |
| \W | Non-word character | \W | @, #, !, space |
| \s | Whitespace character (space, tab \t, newline \n) | \s+ | " ", "\t" |
| [abc] | Character set: matches any of 'a', 'b', or 'c' | [aeiou] | a, e, i, o, u |
| [^abc] | Negated set: matches anything EXCEPT 'a', 'b', or 'c' | [^0-9] | A, b, $, % |
Anchors & Boundaries
| Anchor | Meaning | Example | Behavior |
|---|---|---|---|
| ^ | Beginning of string (or line in multiline 'm' mode) | ^Hello | Matches "Hello" only at string start |
| $ | End of string (or line in multiline 'm' mode) | World$ | Matches "World" only at string end |
| \b | Word boundary position (between \w and \W) | \bcat\b | Matches "cat" but NOT "catfish" or "scat" |
| \B | Non-word boundary position | \Bcat | Matches "cat" inside "scat" |
Quantifiers (Greedy vs Lazy)
| Quantifier | Greedy Meaning | Lazy Variant | Lazy Behavior |
|---|---|---|---|
| * | 0 or more times (matches as much as possible) | *? | Matches 0 or more times (stops at 1st match) |
| + | 1 or more times | +? | Matches 1 or more times lazily |
| ? | 0 or 1 time (optional token) | ?? | Prefers 0 times if possible |
| {n} | Exactly n times | {n} | Exact count (e.g. \d{4} matches 2026) |
| {n,m} | Between n and m times | {n,m}? | Matches n to m times lazily |
Groups & Lookaround Assertions
| Syntax | Type | Description & Purpose |
|---|---|---|
| (...) | Capturing Group | Groups sub-patterns and captures matched text in memory ($1, $2). |
| (?:...) | Non-Capturing Group | Groups sub-patterns without creating a numbered capture (saves memory). |
| (?<name>...) | Named Group | Assigns an explicit name accessible via match.groups.name. |
| (?=...) | Positive Lookahead | Asserts that pattern MUST follow the current position without consuming text. |
| (?!...) | Negative Lookahead | Asserts that pattern MUST NOT follow the current position. |
| (?<=...) | Positive Lookbehind | Asserts preceding text MUST match pattern without shifting match boundaries. |
| (?<!...) | Negative Lookbehind | Asserts preceding text MUST NOT match pattern. |
4. Tested Production Regular Expression Patterns
Select any real-world regex pattern below to inspect its production pattern, target sample input, expected matches, and technical explanation:
1. Pragmatic Email Address Validation
Validates standard email username and domain structures while avoiding ReDoS backtracking risks.
/^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}$/udeveloper.support@toolmono.com
5. JavaScript Regex Flags Explained (g, i, m, s, u, y, d)
ECMAScript regular expressions support seven official modifier flags that customize matching behavior:
g Global Search
Searches for all occurrences across the entire input string rather than terminating execution after the first match.
i Case Insensitive
Ignores character casing, treating lowercase and uppercase letters interchangeably.
m Multiline Anchors
Causes start (^) and end ($) anchors to match at the beginning and end of each individual newline (\n) in addition to string boundaries.
s DotAll Mode
Allows the wildcard dot (.) to match newline characters (\n), enabling cross-line block pattern matching.
u Unicode Support
Enables full 32-bit Unicode code point interpretation for emojis, surrogate pairs, and international scripts.
y Sticky Search
Restricts matching strictly to the character position indicated by the RegExp object's lastIndex property.
d Indices Generation (ES2022)
Generates exact start and end substring indices for each captured group on the match.indices property.
6. Numbered and Named Capture Group Inspection
JavaScript RegExp supports numbered capturing groups, non-capturing groups, and named capturing groups:
Numbered Capture Groups: (...)
Any expression enclosed in unescaped parentheses creates a numbered capture group stored in the match array:
const [full, group1, group2] = "2026-08".match(/(\d{4})-(\d{2})/);
// group1 = "2026" ($1)
// group2 = "08" ($2)Named Capture Groups: (?<name>...)
Assign explicit keys to captured sub-patterns without duplicating array indices:
const match = "2026-08".match(/(?<year>\d{4})-(?<month>\d{2})/);
// match.groups.year = "2026"
// match.groups.month = "08"7. JavaScript String.replace() Substitution Syntax
The ToolMono replacement tool follows standard JavaScript String.prototype.replace() semantics. Use these special replacement tokens:
| Token | Replacement Meaning | Example Pattern | Example Result |
|---|---|---|---|
| $$ | Inserts a literal dollar sign ($) | $$100 | $100 |
| $& | Inserts the entire matched substring | [$&] | [matched_text] |
| $` | Inserts the portion of the string preceding the match | $` | prefix_text |
| $' | Inserts the portion of the string following the match | $' | suffix_text |
| $n | Inserts the Nth 1-indexed captured group ($1, $2, ...) | $2-$1 | 08-2026 |
| $<name> | Inserts the named capturing group <name> | $<day>/$<month> | 23/08 |
8. JavaScript RegExp Engine & Flavor Differences
This online tool uses the JavaScript (ECMAScript) RegExp engine. While core regex constructs behave consistently across platforms, syntax features differ between major engines:
| Engine / Flavor | Engine Model | Lookbehind Support | Atomic Groups (?>...) | Possessive Quantifiers (*+) |
|---|---|---|---|---|
| JavaScript (ECMAScript) | NFA | Variable length (ES2018+) | Not supported natively | Not supported natively |
| PCRE / PHP (preg_*) | NFA | Fixed length only | Supported | Supported |
| Python (re module) | NFA | Fixed length only | Third-party regex only | Third-party regex only |
| Java (java.util.regex) | NFA | Bounded length | Supported | Supported |
| Go (regexp package) / RE2 | DFA | Not supported | Not needed (linear time) | Not needed (linear time) |
9. Catastrophic Backtracking & ReDoS Prevention
Regular Expression Denial of Service (ReDoS) occurs when an NFA regex engine encounters nested quantifiers or ambiguous alternations, causing CPU execution time to grow exponentially ($O(2^n)$) on non-matching strings:
Vulnerable Pattern (ReDoS Risk)
/(a+)+b/
Evaluated against aaaaaaaaaaaaaaaaaaaaaaaaX, the nested quantifier forces the NFA engine to explore $2^24$ execution branches ($16,777,216$ iterations), causing CPU starvation.
ReDoS-Safe Pattern
/a+b/
By removing nested quantifiers and ensuring non-overlapping character classes, execution completes in linear time ($O(n)$) regardless of input payload length.
- Avoid Nested Quantifiers: Never nest unbounded quantifiers like (a+)+ or (a|a)+.
- Use Specific Character Sets: Replace wildcard dots with restricted sets like [^\s] or [a-zA-Z0-9].
- Anchor Pattern Bounds: Anchor inputs with ^ and $ when validating form fields.
- Test Edge Inputs: Test edge cases such as long invalid strings and Unicode boundaries before production release.
10. 100% Client-Side Privacy Guarantee
ToolMono Regex Tester operates 100% locally in your web browser memory:
- Zero Remote Uploads: Your test strings, proprietary log payloads, and regex patterns are compiled and matched exclusively in browser memory.
- Offline Execution: Once loaded, the tool works completely offline without sending network requests.
- No Telemetry of Inputs: We do not log, track, or transmit your regex patterns or test strings.
11. Frequently Asked Questions
12. References & Official Standards
The specifications and documentation resources listed below define regular expression standards across browsers and runtime engines:
ECMAScript Language Specification: RegExp Objects
Official JavaScript specification for Regular Expression syntax and flags.
MDN Web Docs: Regular Expressions Guide
Comprehensive Mozilla developer reference for JS regex syntax.
PCRE: Perl Compatible Regular Expressions Documentation
Official reference manual for PCRE pattern matching engine.