Regex Tester for JavaScript Patterns
Test a JavaScript regular expression against sample text. Adjust the pattern and flags to inspect which parts of the input match.
Regex Tester & Debugger workspace
Live match testing
Matches recompute the moment you change the pattern, flags, or test string.
Inline highlighting
Every match is highlighted in place so you can see exactly what your pattern captures.
Group & index details
Read the match range, numbered $1 $2 groups, and named groups in a structured panel.
100% client-side
Runs on your browser's native RegExp engine. No pattern or text is ever uploaded.
Online Regex Tester for JavaScript Regular Expressions
Test a JavaScript regular expression against sample text. Adjust the pattern and flags to inspect which parts of the input match. Regex syntax and matching behavior vary between engines. This tool follows the browser's JavaScript engine, so a pattern may behave differently in another language. Include matching, non-matching, empty, and long inputs before reusing a pattern in validation.
How to use the regex tester
Build and debug a pattern in five steps. Everything updates live as you change the pattern, flags, or test string.
- Type your pattern in the field between the two
/delimiters — no need to escape the slashes or wrap them yourself. - Toggle the flag pills you need. The default is
gm(global + multiline); click any pill to add or remove it. - Paste or edit the test string below. Every match is highlighted inline and counted in the Match Information panel.
- Open a match to read its index range
[start-end]and any capture groups, shown as$1,$2, with named groups labeled. - Fix the pattern until the highlights and group values are exactly what you expect, then copy it into your code.
Common regex patterns to copy
Paste any of these into the pattern field to start. Each is written for the JavaScript engine; treat the email and phone patterns as format checks, not strict standards validation.
Email shape
^[^\s@]+@[^\s@]+\.[^\s@]+$Checks the basic [email protected] shape, not full RFC 5322 validity.
HTTP/HTTPS URL
^https?:\/\/[^\s$.?#].[^\s]*$Matches links beginning with http:// or https://.
Phone number
^\+?[\d\s-]{10,15}$Optional + prefix, 10–15 digits, spaces, or dashes.
ISO date (named groups)
(?<y>\d{4})-(?<m>\d{2})-(?<d>\d{2})Captures year, month, and day by name.
What is a regular expression and how does this work?
A regular expression is a compact language for describing patterns in text. The browser compiles your pattern with new RegExp(pattern, flags) and runs it against the test string — the same call your own JavaScript uses. This tool follows the JavaScript flavor defined in the ECMAScript RegExp specification, with per-feature behavior documented on MDN's RegExp reference.
Because the engine is JavaScript-specific, a few habits from other flavors do not carry over: there are no possessive quantifiers (a++) and no atomic groups. Modern ES2018 features do work here: named groups (?<name>...), lookbehind (?<=...) and (?<!...), and Unicode property escapes such as \p{L} when the u flag is on.
Worked examples
1. Capture PascalCase words (the default demo)
Pattern ([A-Z])\w+ with flags gm against PascalCase words like FunctionNames matches PascalCase, FunctionNames, and group $1 holds the leading capital (P, F).
2. Multiline anchors
Pattern ^\w+ on three lines returns one match per line with the m flag on. Remove m and you get a single match — the first word of the whole string only.
3. Edge case: the dot does not cross newlines
Pattern a.b against a\nb returns no match, because . excludes newlines by default. Add the s (dotAll) flag and it matches.
4. Failing literal: catastrophic backtracking
Pattern (a+)+$ against aaaaaaaaaaaaaaaaaaaaaaaaaaab can hang the tab. The nested quantifier forces the engine to try exponentially many splits before it gives up. Rewrite it as a+$.
JavaScript regex flag reference
The five flags below are exposed as toggle pills; the default state is gm. The y (sticky), d (hasIndices), and v (unicodeSets) flags exist in the spec but are not toggled here. Note that u and v are mutually exclusive and cannot be combined.
| Flag | Name | What it changes |
|---|---|---|
| g | global | Find all matches instead of stopping after the first. |
| m | multiline | ^ and $ match the start/end of each line, not just the whole string. |
| i | ignoreCase | Casing differences are ignored when matching. |
| s | dotAll | Lets . match newline characters too. |
| u | unicode | Treats the pattern as Unicode code points; enables \p{...} escapes. |
Common token cheat sheet
| Token | Description | Example Matches |
|---|---|---|
| . | Any character (except newline) | a, 1, % |
| \w | Word character | a-z, A-Z, 0-9, _ |
| \d | Digit | 0-9 |
| [abc] | Character set (a, b, or c) | a, b, or c |
| (?:...) | Non-capturing group (no $n slot) | groups without capturing |
| + | One or more quantifier | "a" or "aaaa" |
The 10,000-match guard most testers skip
With the g flag on, this tester stops collecting after 10,000 matches and tells you it hit the cap, instead of freezing while a zero-width or pathological pattern loops forever. It also auto-advances lastIndex past zero-width matches (like (?:) or \b) so the loop cannot stall on an empty match — a classic bug in naive while (regex.exec(...)) code. What it cannot stop is catastrophic backtracking: the native engine has no backtrack budget, so a pattern like (a+)+$ on a long non-matching string can lock the tab. That failure mode is the root of most real-world ReDoS incidents — flatten nested quantifiers before you ship a pattern to a server.
Related developer & text tools
Apply a tested pattern as a substitution
Diff CheckerCompare two strings line by line
Text SorterSort and dedupe matched lines
Case ConverterSwitch captured text between cases
JSON FormatterValidate data you extracted with regex
URL ParserBreak a URL into its parts
HTML Entity ConverterEncode/decode scraped markup
Word CounterCount words, characters, and lines
URL Slug GeneratorSlugify strings with clean rules
Cron Expression BuilderBuild schedules with field syntax
New to pattern syntax? Read the guides on the Toolk blog for a full regex cheat sheet and worked walkthroughs.
Last updated: September 15, 2026 · Runs 100% in your browser — no uploads, tool input is not sent to Toolk.
Frequently asked questions
Which regex flavor does this tester use, and what does not carry over?
It runs your browser's native JavaScript engine per the ECMAScript RegExp specification, so results match production code exactly. Habits from other flavors will fail here: no possessive quantifiers like a++ and no atomic groups. Modern ES2018 additions do work — named groups (?<name>...), lookbehind, and \p{...} Unicode property escapes when the u flag is on.
Why does my pattern match on one line but skip text after a newline?
The dot excludes newline characters unless you enable the s (dotAll) flag, so a.b finds nothing in a\nb until s is toggled on. Anchors have their own trap: without m (multiline), ^ and $ only bind to the start and end of the entire string rather than each line.
Is my pattern or test data sent anywhere while I type?
No. Matching happens locally on your browser's built-in RegExp engine with zero network calls, so both your pattern and your sample text stay on your device — Toolk's page analytics never receive them — and the tester keeps working offline once loaded.
The page froze on one pattern — what happened?
That is catastrophic backtracking: a nested quantifier such as (a+)+$ forces the native engine through exponentially many splits on long non-matching input, and it has no internal backtrack budget. Flatten nested quantifiers before shipping patterns to a server — then reuse them directly in Toolk's find-and-replace tool (/tools/find-and-replace) to apply matches as substitutions.