Regex Tester (JavaScript)

Enter a pattern, flags and sample text to see every match and group — computed in your browser.

Runs in your browser — nothing you enter is uploaded

Regex Tester

All fields are required unless marked “optional”.

Without the surrounding slashes

g global, i ignore case, m multiline, s dot-all, u unicode, y sticky, d indices

Use $1, $2 or $<name> to insert groups

Tip: press Ctrl+Enter (Cmd+Enter on Mac) inside a text box to run.

Your result will appear hereFill in the fields and press “Test”.

Formula

  • new RegExp(pattern, flags) applied with matchAll / exec
  • Matches are reported with their position in the text.
  • Zero-length matches are counted but not highlighted.

The tool runs the same regular-expression engine that JavaScript uses.

Worked example

Two numbers around a dash

Pattern
(\d+)-(\d+)
Flags
g
Test text
a 10-20 b 3-4

Matches

2

Flags used: g

Capture groups: 2

How it works

The pattern is compiled with the browser's own RegExp engine and run over your text. Each match is listed with its start position and the value of every capture group, numbered or named, and matches are highlighted in the text. Add a replacement to preview the result of String.replace, where $1 refers to the first group.

Regular-expression syntax differs between languages: lookbehind, named groups and Unicode property escapes work here as in modern JavaScript, but Python, PCRE and Java have their own differences. Patterns with nested repetition (such as (a+)+) can be very slow on some inputs because of backtracking, and a pathological pattern can freeze this tab, so inputs are capped at 100,000 characters and 1,000 matches. See also Word Counter and Case Converter for simpler text tasks, or the JSON Validator for data checks.

Assumptions and limits

  • JavaScript (ECMAScript) syntax only.
  • No timeout is applied, so extremely complex patterns can make the page unresponsive until you reload it.