Skip to content

Regex Tester

Type a regular expression and see matches, capture groups, and positions update live. Copy the full result or restore the example with Clear.

Type the pattern without the wrapping slashes; set flags in the next field. Full literal looks like /pattern/flags e.g. /\d+/g. Tokens: ^ $ \d \w .* [a-z] (group).

Toggle or type. g lists every match; without g only the first. d is added automatically for positions.

Quick reference
\ddigit\wword char\swhitespace.any char ^start$end*0++1+ ?optional{2,4}repeat[a-z]class(…)group (?:…)non-capture(?…)named group|or\bboundary
Matches
Full expression — copy for code
/\d+/g

Slash-escaped literal /pattern/flags and constructor new RegExp("pattern", "flags") update live as you type.

Positions are 0-based ranges — end is exclusive, so value equals text.slice(start, end).

The match list updates as you type. The page loads with the pattern \d+ and the text “Order 42 shipped”, so it already shows one match: the number 42 at positions 6-8.

What the Regex Tester shows

Each row lists the match number, the start and end positions, and the matched text. Positions count from zero and the end is exclusive, so the value equals text.slice(start, end). Capture groups appear under their match, numbered from left to right. With (\d+)-(\d+) against “Order 42-17 shipped, ref 7-9” the list shows Match 1 at 6-11 with Group 1 at 6-8 (“42”) and Group 2 at 9-11 (“17”), then Match 2 at 25-28 with Group 1 at 25-26 (“7”) and Group 2 at 27-28 (“9”). A pattern that matches empty text, like a*, produces an empty match row at each position, and an optional group that did not participate shows “not matched”.

How to test a regular expression

  1. Type the pattern in the Pattern box.
  2. Set the flags in the Flags box. The default is g, and the allowed letters are d g i m s u v y.
  3. Paste the text you want to test in the Test text box.
  4. Read the match list on the right. Run jumps to the result, Copy result copies the status line and the list, and Clear restores the starting example.

Flags and the g flag

With g the tool lists every match. Without g it lists only the first match, which is how JavaScript treats non-global expressions. Any other flag letter stops the test with an error message naming the letter.

Limits and errors

The test text is limited to 100,000 characters. The match list stops at 5,000 matches and the status line says so. Above 50,000 characters the highlight preview is hidden, while the match list still covers the full text. An invalid pattern, such as an unclosed [, stops the test and shows the native JavaScript error text. An empty pattern or empty text shows a prompt message instead of running.

Related tools

More utilities you may find useful.

View all tools