Skip to content

Regex Tester for JavaScript

This regex pattern tester highlights every match as you type. Inspect capture groups, preview replacements and splits, and switch flags on and off, all with the JavaScript regex engine.

Pattern

Results update as you type. Matching runs in a background worker and stops after 2 seconds.

Waiting for regex
Ready. Enter a regex pattern and some test text.

Test against a file

Drop a text, log, CSV, JSON or code file here. It is read in your browser, not uploaded.

StatusWaiting
Flagsg
Matches0
Groups0
Input Size0 chars
Primary Output0 chars

Test text and result

Paste text on the left. The right panel shows the view chosen under Primary view.

Pattern idle View idle

Test Text

0 chars 0 lines
Waiting for test text
No file loaded

Primary Output

Highlighted text 0 chars
No result yet
No active match

Regex Snapshot

Quick stats for your current pattern, matches, groups, text size, and replacement output.

Snapshot idle
Regex—
Pattern Length0
Match Count0
Unique Matches0
Replacement Size0 chars
Split Parts0

Errors & Parser Notes

Invalid syntax, unsupported flags, zero-length behavior, and quick debugging details appear here.

Run the regex to see validation notes here.

Matches & Groups

Inspect every match with its index, matched value, and captured groups.

Matches idle
Run your regex to inspect matches here.

Replace Preview

See the output produced by text.replace(regex, replacement).

Replace idle
Run the regex to see replacement preview here.

Split Preview

See how your text is split when the regex is used with text.split(regex).

Split idle
Run the regex to see split output here.

Runs in your browser. Nothing you type, paste or open here is uploaded.

To test a regex, type your pattern into Regex Pattern without the surrounding slashes, tick the flags you need, and paste sample text into Test Text. Matches are highlighted as you type, and each one is listed with its index and capture groups. Select Run to rerun it, or use Next match to step through results.

How to use the regex tester

  1. Enter a pattern. Type it in Regex Pattern, for example \b\d{3}-\d{4}\b, without slashes. Or choose a Quick Preset such as Email addresses or Dates YYYY-MM-DD.
  2. Add test text. Paste it into Test Text, or select Choose file under Test against a file to load a log, CSV, JSON or code file.
  3. Set flags and mode. Tick g, i, m, s, u, y or d. Match Mode can find all matches, only the first, or just test whether there's a match.
  4. Read the results. Matches highlight live. Change Primary View to Replace preview, Split preview or Raw match summary, and check Matches & Groups for each capture.

A JavaScript regex tester: what that means

Regex syntax varies between languages. This tester compiles your pattern with JavaScript's built-in RegExp, exactly as new RegExp(pattern, flags) would in your browser or Node.js, so what matches here matches in your JavaScript code. Errors appear under Errors & Parser Notes with the browser's own message.

Most everyday syntax is shared with Python, PHP (PCRE) and Java: character classes, quantifiers, groups, lookahead and backreferences. A few things differ. JavaScript has no \A or \Z anchors, so use ^ and $; it has no possessive quantifiers or atomic groups; and named groups use (?<name>...).

When you're done, Copy /pattern/flags copies a literal like /\d+/g. If your pattern contains a forward slash, escape it as \/ before pasting the literal into code.

Regex cheat sheet

TokenMatches
.Any character except a line break (any character with the s flag)
\d \w \sA digit, a word character (letter, digit, underscore), whitespace
\D \W \SThe opposite of each of the above
\bA word boundary
^ $Start and end of the text (of each line with the m flag)
[abc] [^abc] [a-z]One of, none of, or a range of characters
* + ? {2,5}0 or more, 1 or more, 0 or 1, between 2 and 5
*? +?Lazy versions that match as little as possible
(abc) (?:abc)Capturing group, non-capturing group
(?<year>\d{4})Named capturing group
\1Backreference to group 1
a|ba or b
(?=x) (?!x)Followed by x, not followed by x
(?<=x) (?<!x)Preceded by x, not preceded by x

To match a special character such as ., ? or ( literally, put a backslash in front of it. Escape text does that for you: it takes the text in Test Text and turns it into a pattern that matches it exactly.

JavaScript regex flags explained

  • g (global) finds every match instead of stopping at the first. Find all matches mode always searches globally.
  • i (ignore case) makes a match A.
  • m (multiline) lets ^ and $ match at each line break.
  • s (dotAll) lets . match line breaks too.
  • u (unicode) treats emoji and other characters outside the Basic Multilingual Plane as one character and enables \p{...} property escapes such as \p{L} for any letter.
  • y (sticky) only matches starting exactly where the previous match ended.
  • d (indices) makes exec() results include start and end positions for each group. The tester accepts it, though its list shows each match's start index only.

Regex replace and split preview

The Replacement field uses the same syntax as JavaScript's String.replace(): $1 and $2 insert numbered groups, $<name> a named group, $& the whole match and $$ a literal dollar sign. For example, pattern (\d{4})-(\d{2})-(\d{2}) with replacement $3/$2/$1 turns 2026-10-11 into 11/10/2026. Without the g flag only the first match is replaced, just as in your code.

Split preview shows the parts produced by text.split(regex), numbered from 0. Capturing groups in the pattern are included in the split results: use (?:...) if you don't want them. To compare a replaced result with the original, paste both into the diff checker.

Why is my regex slow or not matching?

  • Catastrophic backtracking. Nested quantifiers like (a+)+$ or (\w+\s?)*$ can take exponential time on text that almost matches. This tester runs each match in a background worker and stops it after 2 seconds with a timed-out message, so the page stays usable, but in production the same pattern can stall a server (known as ReDoS). Avoid nesting quantifiers.
  • Greedy matching. <.*> matches from the first < to the last > on the line. Use the lazy <.*?> or <[^>]*>.
  • Double escaping in strings. In new RegExp("\\d+") the backslash must be doubled. In this tester, type the pattern as you would inside a /literal/.
  • The g flag and test(). A global regex remembers lastIndex, so calling test() twice on the same string can return true and then false.

For regex work on JSON, check the data's structure first in the JSON formatter.

Frequently asked questions

Which regex engine does this regex tester use?

It uses your browser's JavaScript RegExp engine, so results match what JavaScript code in that browser or in Node.js produces. Other languages such as Python and PHP may treat some syntax differently.

Do I include the slashes around the pattern?

No. Type only the pattern, such as \d+, and choose flags with the checkboxes. Copy /pattern/flags gives you the full literal for your code.

How do I see capture groups?

Every match in the Matches & Groups panel lists its groups as Group 1, Group 2 and so on. Named groups appear by their number. Raw match summary shows the same data as plain text.

Is there a limit on matches?

Find all matches stops at 10,000 matches and adds a note. Matching also stops if it takes longer than 2 seconds.

Is my test text uploaded?

No. The pattern, test text and any file you open stay in your browser. Matching runs locally.

What does the regular expression tester's Test only mode do?

It checks whether the pattern matches anywhere, like regex.test() in JavaScript, and shows just the first match. Use it for validation patterns where you only need a yes or no.

Updated 11 October 2026Reviewed by the ToolzyLab teamHow we test our tools