Regex Tester

Test regular expressions with flags (g, i, m, s, u) and inspect matches, positions, and capture groups locally.

Ready. Enter a regular expression pattern and test string below.
Matches: 0

Matches & Capture Groups

# Offset Full Match ($0) Capture Groups ($1, $2, ...)
No matches evaluated yet.

About the JavaScript Regex Tester

This tool runs your pattern using the browser's native ECMAScript RegExp engine. Common flags include g (global match), i (case-insensitive), m (multiline ^ and $), s (dotAll: . matches newlines), and u (Unicode mode).

Safety & Engine Notes: Input is capped at 100,000 characters and 500 matches per run, and zero-length matches automatically advance the cursor to prevent infinite loops. Avoid nested unbounded quantifiers (such as (a+)+) that can cause catastrophic backtracking in JavaScript's NFA engine.

Positional & Named Capture Groups

Inspect every match's character offset index, full match string ($0), and individual numbered or named capture groups ((?<name>...)) in a structured table.

Full ECMAScript Flag Support

Combine global (g), case-insensitive (i), multiline anchor (m), dotAll newline (s), and Unicode property escape (u) flags to match your production runtime.

Zero-Length Loop Guard

Patterns that can match empty strings (such as ^, $, or a*) automatically increment lastIndex so global iteration completes safely without freezing the browser tab.

Frequently Asked Questions

Why does my regex only return the first match?

Make sure the g (global) flag is included in the flags box. Without g, RegExp.prototype.exec() stops after finding the first match in the input string.

How do I prevent ReDoS (Regular Expression Denial of Service) in production?

Avoid nested quantifiers with overlapping character classes (like (a+)+$ or (\w+\s?)*), prefer possessive/atomic alternatives or bounded quantifiers ({1,64}), and validate input string length before executing complex regular expressions.