Skip to main content

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

// gm
Test String
222 chars
Preview
WelcomeMatch #1 to the RegexMatch #2 TesterMatch #3 tool! ThisMatch #4 tool helps you debug your regular expressions. PascalCaseMatch #5 words like specific FunctionNamesMatch #6 are matched here. ExampleMatch #7 without email trigger: user_at_toolk_dot_site PhoneMatch #8: 123-456-7890
Match Information8 Matches
Match #1Indices: [0-7]
Welcome
Groups
$1W
Match #2Indices: [15-20]
Regex
Groups
$1R
Match #3Indices: [21-27]
Tester
Groups
$1T
Match #4Indices: [34-38]
This
Groups
$1T
Match #5Indices: [86-96]
PascalCase
Groups
$1P
Match #6Indices: [117-130]
FunctionNames
Groups
$1F
Match #7Indices: [149-156]
Example
Groups
$1E
Match #8Indices: [203-208]
Phone
Groups
$1P

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.

  1. Type your pattern in the field between the two / delimiters — no need to escape the slashes or wrap them yourself.
  2. Toggle the flag pills you need. The default is gm (global + multiline); click any pill to add or remove it.
  3. Paste or edit the test string below. Every match is highlighted inline and counted in the Match Information panel.
  4. Open a match to read its index range [start-end] and any capture groups, shown as $1, $2, with named groups labeled.
  5. 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.

FlagNameWhat it changes
gglobalFind all matches instead of stopping after the first.
mmultiline^ and $ match the start/end of each line, not just the whole string.
iignoreCaseCasing differences are ignored when matching.
sdotAllLets . match newline characters too.
uunicodeTreats the pattern as Unicode code points; enables \p{...} escapes.

Common token cheat sheet

TokenDescriptionExample Matches
.Any character (except newline)a, 1, %
\wWord charactera-z, A-Z, 0-9, _
\dDigit0-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.

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.

Need a different tool?

Browse all 103 browser-based tools (103 currently marked free), or tell us what useful utility we should build next.

Browse all tools