Regex Tester

Runs 100% in your browser

Test JavaScript regular expressions against any sample text — every match highlighted, capture groups listed, named groups resolved, replace preview, all flags, pattern history, and a quick-reference cheat sheet. Free, 100% browser-local.

/ / g
TEST STRING Ctrl+Enter to run
HIGHLIGHTED MATCHES Ready
HISTORY Up to 8 patterns — memory only
  • No history yet.
?? Tip: Ctrl+Enter runs the match immediately.  |  Use (?<name>pattern) for named capture groups — they appear as $<name> in replace.  |  The g flag is always on so all matches are found.
Your patterns and test strings never leave your browser. No upload, no server, no account required.

Frequently asked questions

A Regex Tester is a browser tool for writing, testing, and debugging regular expressions against sample text. You type a pattern, paste a test string, and the tool immediately shows every match highlighted, the match index and length, capture group values, and replace output. ToolsSonic's Regex Tester targets the JavaScript RegExp engine directly — so patterns you validate here work identically in Node.js, browsers, and JavaScript-based tools.

All six JavaScript regex flags: g (global — find all matches), i (case-insensitive), m (multiline — ^ and $ match line boundaries), s (dotAll — dot matches newlines), u (unicode — full Unicode property support), and y (sticky — match from lastIndex position only). The g flag is always enabled so all matches are found and listed. Toggle any other flag individually with the checkboxes above the test string.

A capturing group is a parenthesised sub-pattern such as (\d{4}). Each match shows a "Capture Groups" table with the value for every numbered group ($1, $2, etc.) across all matches. For named groups — written as (?<name>pattern) — the table shows $<name> columns. Groups that did not participate in a match show — (a dash) rather than undefined.

Named capture groups use the syntax (?<groupName>pattern). For example (?<year>\d{4})-(?<month>\d{2}) extracts year and month with meaningful names. In the Replace field you reference them as $<year> and $<month>. Named groups appear as separate columns in the Capture Groups table and are listed alongside numbered groups in each Match entry.

Enable "replace mode" with the checkbox in the flags row. A replacement string input appears below the flags. Type a replacement string — use $& for the whole match, $1/$2 for numbered groups, $<name> for named groups, $` for the string before the match, and $' for the string after the match. The Replace Result panel shows the full test string after all substitutions, updated live as you type.

The g (global) flag finds all non-overlapping matches from left to right through the entire string. The y (sticky) flag finds a match only at the position stored in lastIndex and fails if the pattern does not match there — making it useful for tokenizers that step through input sequentially. In this tester with both g and y enabled, the engine performs global sticky matching, advancing lastIndex after each match.

In JavaScript, the dot metacharacter matches any character except a newline (\n, \r, \u2028, \u2029). This is the default behavior for historical compatibility with single-line log-line matching. Enable the s (dotAll) flag to make the dot match newlines as well. When s is on, patterns like .+ match across line boundaries.

Without the m (multiline) flag, ^ matches only at the very start of the entire test string and $ matches at the very end. With the m flag enabled, ^ matches at the start of any line (immediately after a newline character) and $ matches at the end of any line (immediately before a newline). This is especially useful when running patterns against multi-line log output or multi-line textarea content.

The u (unicode) flag enables full Unicode mode, which has several effects: surrogate pairs are treated as single code points, Unicode property escapes like \p{Letter} and \p{Script=Latin} become available, and invalid escape sequences throw errors rather than silently passing. If you are matching multilingual text — accented letters, Cyrillic, CJK, emoji — enabling the u flag gives you more accurate results than the default mode.

Zero-length matches — produced by patterns like \b, (?=x), or .* at the end of a string — are fully supported. The match list shows them as "empty" entries with length 0. When the g flag is active and a zero-length match occurs, the tester advances the lastIndex by one character to avoid an infinite loop and continues searching, matching the JavaScript specification.

A regex tester validates an existing pattern against sample text — it shows you what matches, what capture groups capture, and what a replacement produces. A regex generator (also called a regex builder) creates a pattern from a description or visual input. ToolsSonic offers both: this Regex Tester for validation and debugging, and a companion Regex Generator for building patterns from scratch.

regex101 supports multiple engines (PCRE2, Python, ECMAScript, Java, .NET) with a full syntax explainer and debugger. ToolsSonic's Regex Tester targets the JavaScript engine specifically, with no login, no page weight, all-flag support including u and y, named group columns in the capture table, live replace preview, a quick-reference cheat sheet, session history, and zero server round-trips. For JS/Node development workflows it is faster and more private.

Every time you run a match with a non-empty pattern, the pattern is saved to a session history list (up to 8 entries). Each entry shows the pattern and the time it was last used. Clicking a history entry restores the pattern and test string to the inputs and re-runs the match. History is stored in browser memory only — it is cleared when you close the tab and is never written to localStorage or sent to a server.

Yes. The test string textarea accepts multi-line input. Press Enter to insert newlines, or paste multi-line content. Enable the m flag to make ^ and $ match at line boundaries. Enable the s flag to let the dot match newlines. The highlighted output preserves line breaks and shows each match in context.

Yes. JavaScript supports positive lookahead (?=...), negative lookahead (?!...), positive lookbehind (?<=...), and negative lookbehind (?<!...). These are zero-width assertions — they do not consume characters, so they do not appear as a match value, but they constrain where a match can occur. The quick-reference cheat sheet on this page lists all assertion types with examples.

Yes, when the u flag is enabled. Unicode property escapes match characters by their Unicode category: \p{Letter} matches any letter in any script, \p{Decimal_Number} matches any decimal digit, \p{Script=Greek} matches Greek script characters. They are available in modern browsers (Chrome 64+, Firefox 78+, Safari 11.1+, Edge 79+) and Node.js 10+. If the browser does not support the syntax, the pattern throws a SyntaxError and the tester shows the error message.

The collapsible Quick Reference table lists the most commonly used regex tokens and their meanings: metacharacters (. \d \w \s \b), anchors (^ $), quantifiers (* + ? {n} {n,m} and their non-greedy variants), character classes ([abc] [^abc]), group types (capturing, non-capturing, named), lookaheads and lookbehinds, and alternation (a|b). A second section lists the replacement string tokens: $& $1 $2 $<name> $` $' $$.

Not directly — the tool does not include a file open button for the test string. You can open a file in any text editor, select all, copy, and paste into the test string textarea. For very large files, consider running the pattern in the browser console or Node.js REPL where you can load the file programmatically. The tester is optimised for interactive development rather than batch processing.

No. The entire tester runs in browser memory. The JavaScript RegExp engine is built into every browser, so there is no reason to send data to a server. No fetch, XMLHttpRequest, sendBeacon, localStorage, sessionStorage, or IndexedDB is used at any point. Closing the tab clears everything. You can verify this in DevTools → Network — zero outbound requests are made during any regex operation.

The built-in Load Sample button populates the pattern with a standard email validation regex (\b[A-Za-z0-9._%+\-]+@[A-Za-z0-9.\-]+\.[A-Za-z]{2,}\b) and a test string with three valid addresses and three invalid ones. It demonstrates boundary anchors, character classes, quantifiers, and real-world match highlighting in a single click.

Yes. ToolsSonic's Regex Tester is completely free with no account, no rate limit, no watermark, and no upload. All features — all flags, capture-group table, named groups, replace mode, quick-reference cheat sheet, session history, and pattern copy — are available at no cost, with no ads or paywalls.

Yes. Open the Explain pattern panel and every token is broken down in plain English — anchors, character classes, quantifiers, capture and named groups, lookaheads and lookbehinds, backreferences, and Unicode escapes. The explanation updates live as you type.

JavaScript RegExp — the same engine that runs your pattern here. Most tokens behave identically in PCRE and Python, but flavor-specific features such as possessive quantifiers or atomic groups do not exist in JavaScript and will be treated as literals or errors.

The Tester is for debugging a pattern you already have: live matches, groups, replacement, and a token-by-token explanation. The Generator builds a pattern for you from presets and plain-language goals. They link to each other, so you can generate a pattern and then test it.

What is Regex Tester?

A regular expression (regex) tester is a developer tool for writing, debugging, and validating regex patterns against sample text. You type a pattern, paste a test string, and the tester immediately shows every match highlighted in the input, lists each match with its start index and length, and displays capture group values for every numbered and named group. You can toggle the full set of JavaScript flags — global, case-insensitive, multiline, dotAll, unicode, and sticky — individually, and preview the result of a string replacement using group references like $1 and $<name>.

Why JavaScript regex matters

JavaScript's built-in RegExp engine is used across every Node.js backend, every browser application, every Deno and Bun script, and every frontend framework from React to Vue. Patterns you test here with ToolsSonic work identically in production code. Unlike PCRE-based online testers (which target PHP, Python, or Perl), ToolsSonic's tester targets the ECMAScript specification directly — so there are no engine translation surprises when you copy a pattern into your codebase.

Capture groups, named groups, and replace

Regular expressions become much more powerful once you use capturing groups. A numbered group like (\d{4}) captures the matched characters and makes them available as $1 in a replacement string or as the first element of the match array. Named groups like (?<year>\d{4})-(?<month>\d{2}) produce readable references in both the groups table ($<year>, $<month>) and in replace strings. ToolsSonic renders a dedicated Capture Groups table that shows, for every match, the value of every numbered and named group side by side — making it easy to see which groups fire on which matches.

All six JavaScript flags

JavaScript's RegExp accepts six flag characters. g (global) finds all non-overlapping matches rather than stopping at the first. i (case-insensitive) treats uppercase and lowercase letters as identical. m (multiline) makes the ^ and $ anchors match at line boundaries rather than only the start and end of the whole string. s (dotAll) extends the dot metacharacter to match newlines — essential for patterns that span multiple lines of a log entry or document. u (unicode) activates full Unicode mode: surrogate pairs become single code points, \p{Letter} and other Unicode property escapes become available, and invalid escape sequences throw errors. y (sticky) constrains matching to the current lastIndex position, enabling efficient sequential tokenizers. ToolsSonic keeps the g flag permanently active so all matches are listed, and exposes the other five as individual toggles.

Common use cases

  • Testing email, phone, ZIP code, and URL validation patterns before adding them to a form validator
  • Debugging log parsing scripts — verifying which lines a pattern matches and whether capture groups extract the right fields
  • Building find-and-replace patterns for code editors and CI scripts with group-reference previews
  • Extracting structured data (dates, IDs, prices) from plain text or API responses
  • Learning regex syntax interactively using the quick-reference cheat sheet alongside a live test string
  • Verifying that Unicode property escapes work in the target browser version
  • Prototyping tokenizer patterns with the sticky flag before implementing them in a lexer
  • Checking replace output before committing a sed or String.prototype.replace call in production code

Why use ToolsSonic's Regex Tester?

ToolsSonic's Regex Tester is the fastest and most private regex101.com alternative for JavaScript developers. While regex101 supports PCRE2, Python, Java, and .NET alongside ECMAScript, ToolsSonic focuses exclusively on JavaScript — giving you correct JS engine behavior with zero account friction and zero server round-trips. Features that set ToolsSonic apart: named capture group columns in the match table ($<year>, $<month> etc.), live replace-mode preview with all $-token references, all six JS flags individually toggleable, a colour-coded match highlighter that distinguishes successive matches by hue, a collapsible quick-reference cheat sheet, session history (8 patterns), Ctrl+Enter shortcut, and full dark mode. Everything runs in the browser. Your patterns and test strings never leave your device.

JavaScript Regex Token Quick Reference

TokenMatchesExample
.Any character except newline (all chars with s flag)c.t → "cat", "cut"
\dDigit [0-9]\d{4} → "2024"
\wWord character [A-Za-z0-9_]\w+ → "hello_world"
\sWhitespace (space, tab, newline)foo\sbar → "foo bar"
\bWord boundary (zero-width)\bword\b matches whole word
^Start of string (or line with m)^Hello
$End of string (or line with m)world$
*0 or more (greedy)ab*c → "ac", "abc", "abbc"
+1 or more (greedy)ab+c → "abc", "abbc"
?0 or 1 (optional)colou?r → "color", "colour"
{n,m}Between n and m times\d{2,4} → 2–4 digits
[abc]Any of: a, b, or c[aeiou]
[^abc]Any character except a, b, c[^\d]
(abc)Capturing group → $1(\d{4})-(\d{2})
(?:abc)Non-capturing group(?:https?://)
(?<name>abc)Named capturing group(?<year>\d{4})$<year>
(?=abc)Positive lookahead\d+(?= dollars)
(?!abc)Negative lookahead\d+(?! cents)
a|bAlternation (a or b)cat|dog

ToolsSonic Regex Tester vs Competitors

FeatureToolsSonicregex101.comregexr.comregexpal.com
JavaScript engine✅ Native browser✅ ECMAScript mode
Named capture groups✅ Column table⚠ Basic
Replace mode with $-tokens✅ Live preview
All 6 JS flags (g/i/m/s/u/y)⚠ g/i/m only
Match colour coding✅ 8 coloursSingle colour
Session history✅ 8 patterns✅ (requires account)⚠ URL share
Cheat sheet✅ Inline✅ Sidebar✅ Sidebar
No account needed⚠ Full history needs account
Dark mode
Zero network requests❌ Saves to server❌ URL saves
100% private — runs in your browser Instant — no server round-trip Free forever — no account needed