Text & Code

Regex Tester

Test JavaScript regular expressions with live match highlighting, capture groups, named groups, match positions, and replacement preview.

● LOCAL ● NO NETWORK ● ECMAScript RegExp

Character classes

. Any char (except newline)
\w Word char [a-zA-Z0-9_]
\d Digit [0-9]
\s Whitespace
\W \D \S Negations
[abc] Character set
[^abc] Negated set
[a-z] Range

Quantifiers

* 0 or more
+ 1 or more
? 0 or 1
{n} Exactly n
{n,} n or more
{n,m} Between n and m
*? +? ?? Lazy (non-greedy)

Groups & anchors

(abc) Capture group
(?<name>abc) Named group
(?:abc) Non-capture group
(?=abc) Lookahead
(?!abc) Neg. lookahead
(?<=abc) Lookbehind
^ $ Start / end
\b \B Word boundary

Flags

g Global (all matches)
i Case-insensitive
m Multiline (^ $ per line)
s DotAll (. matches \n)
u Unicode mode
v Unicode sets (ES2024)
d Indices (hasIndices)

Quick examples

Share an example

The link includes your pattern and flags. Anyone with the link can read the included input. Use examples without secrets.

Related Workflow: Testing patterns against structured data? Use the JSON Formatter to inspect payloads, or use Text Diff to inspect line-by-line differences before and after regex replacements.

About JavaScript RegExp & Dialects

What it does

The Regex Tester evaluates a JavaScript regular expression against sample text and shows all matches highlighted inline. Each match is listed with its position, full value, numbered capture groups, and named capture groups. The replacement tab previews how String.prototype.replace() would transform the input. All processing happens in your browser using the native ECMAScript RegExp engine.

How it works

Patterns are compiled with new RegExp(pattern, flags). Matches are found using re.exec() in a loop. At most 5000 matches are displayed, and zero-length global matches advance by a character. The global flag controls whether one or all matches are returned. Named groups are exposed via match.groups in supporting browsers. The d flag adds match indices; it is not required for named groups.

No data leaves your browser. Pattern, flags, and test string may be saved in localStorage so you can resume where you left off.

Worked JavaScript regex examples

Find a number before px

\d+(?=px)

With g and text width: 24px; gap: 8px, matches are 24 and 8. The lookahead checks px without including it.

Read named date groups

(?<year>\d{4})-(?<month>\d{2})-(?<day>\d{2})

For 2026-10-18, year is 2026, month is 10, and day is 18. This checks shape, not calendar validity.

First match versus all matches

cat

With text cat dog cat and no flags, only the first cat matches. Enable g to see both.

Common mistakes & Dialect Differences

Limitations