Skip to content
devutils.info

Code Tools · Guide

Regex Tester guide

Test JavaScript regular expressions with live match highlighting and capture groups.

Open the Regex Tester

About the Regex Tester

Regular expressions describe text patterns for searching, validating and extracting data. A small mistake — a missing escape or a greedy quantifier — can make a pattern match far more or far less than intended.

This tester runs your pattern with the JavaScript (ECMAScript) regex engine used by browsers and Node.js, highlights every match, lists capture groups and counts results as you type.

How to use

  1. Enter a pattern without surrounding slashes, e.g. \d{3}-\d{4}.
  2. Toggle flags: g (all matches), i (ignore case), m (multiline ^/$), s (dot matches newlines), u (Unicode) and others.
  3. Type or paste test text. Matches are highlighted and listed with their position and capture groups.
  4. Pick a sample pattern to start from a working example.

Examples

Extract ISO dates with named groups

Input

(?<year>\d{4})-(?<month>\d{2})-(?<day>\d{2})

Output

2026-11-23 → year=2026, month=11, day=23

Case-insensitive word match

Input

\bcolou?r\b  (flags: gi)

Output

Matches “color”, “Colour”, “COLOR”

Regular expression basics

  • . any character · \d digit · \w word character · \s whitespace
  • * 0 or more · + 1 or more · ? optional · {2,5} between 2 and 5
  • ^ start · $ end · \b word boundary
  • [abc] character class · (…) capture group · (?<name>…) named group · (?:…) non-capturing group
  • a|b alternation · (?=…) lookahead · (?<=…) lookbehind

Protection against runaway patterns

Some patterns, such as (a+)+$, take exponential time on certain inputs (“catastrophic backtracking”). Matching runs in a background Web Worker with a time limit; if a pattern takes too long, it is stopped and you'll see a warning instead of a frozen tab. Results are capped at 10,000 matches.

Frequently asked questions

Which regex flavor does this use?

JavaScript (ECMAScript) regular expressions, as implemented by your browser. Syntax such as possessive quantifiers or atomic groups from PCRE, Python or Java may not be supported.

Why does only one match appear?

Without the g (global) flag, JavaScript stops at the first match. Enable g to find all matches.

Do I need to escape forward slashes?

No. Enter the pattern as you would pass it to new RegExp(...). Slashes only need escaping inside a /regex/ literal in source code.

Why did my pattern time out?

It probably contains nested quantifiers that cause catastrophic backtracking. Make quantifiers more specific (e.g. [^,]* instead of .*) or remove nested repetition.

Ready to try it? Everything runs locally in your browser.

Open the tool