Skip to content
kitto works
All tools

Regex Tester | JavaScript Pattern Matching & Capture Groups

Test JavaScript regular expressions instantly, see highlighted matches, and inspect numbered and named capture groups. Everything runs in your browser only — your pattern and text are never sent anywhere.

Flags

The pattern and text you enter are processed entirely in your browser and are never sent anywhere.

Result

Enter a pattern and a test string to see the matches instantly.

How to use

  1. Enter a regular expression pattern and the flags you need (g, i, m, s, u).
  2. Enter the text you want to test against.
  3. The match count, highlighted text, and capture group values appear instantly.

How it works

Supported flags

  • g (global): finds all matches. Without it, only the first match is returned.
  • i (case insensitive)
  • m (multiline): ^ and $ match the start/end of each line.
  • s (dotAll): . also matches newline characters.
  • u (Unicode): treats surrogate pairs and \u{...} escapes as single code points.

About the match results

For each match, the tool shows the matched text, its start position and length, plus the value and start position of every numbered capture group ((...)) and named capture group ((?<name>...)). A group that did not participate in the match is shown as "(did not participate)".

Catastrophic backtracking (ReDoS) mitigation and its limits

JavaScript's regular expression engine can take exponentially longer to process certain inputs (such as a long string that almost, but doesn't quite, match) when the pattern contains a "nested quantifier" — a group wrapped in a quantifier (+/*) that itself contains another quantifier, like (a+)+. This can freeze the browser tab for a long time, a problem generally known as catastrophic backtracking or ReDoS.

Before running your pattern, this tool checks for the typical nested-quantifier shape and refuses to execute it if found, showing an error instead. This check only covers the most common dangerous shape; there are patterns it cannot detect, such as combinatorial blowups from alternation (e.g. (a|aa)+). If the page becomes slow or unresponsive, close the tab and reopen it.

Input size limits

The pattern is limited to 1,000 characters and the text to 200,000 characters. With the global flag, the number of matches is capped at 5,000; anything beyond that is truncated.

Out of scope

This tool does not support replacement/substitution, natural-language explanations of a pattern, or switching to other languages' regex engines (Python, PHP, etc.). It focuses specifically on how a pattern behaves under JavaScript's regex engine.

FAQ

Is my pattern or text sent anywhere?

No. All regex matching happens entirely in your browser. Nothing is sent to any server.

Which flags are supported?

g (global), i (case insensitive), m (multiline), s (dotAll), and u (Unicode) are supported. The y (sticky) flag is not.

Why do some patterns produce an error?

Patterns containing a "nested quantifier" (a quantified group that itself contains another quantifier, like (a+)+) can trigger catastrophic backtracking, making the browser unresponsive on certain inputs. This tool detects that shape before running the pattern and shows an error instead. The check only covers the most common dangerous shape and cannot catch every risky pattern.

Can I replace matched text?

No. This tool focuses on pattern validation and match inspection; it does not offer a replace/substitution feature.

Will I get the same result in other languages like Python or PHP?

Not necessarily. This tool reflects JavaScript's regex engine exactly. Other languages may differ in syntax or behavior (for example, named group syntax or support for lookbehind).