DevRivet
Tools

Regex Tester

A JavaScript regular expression tester: see every match, its index and capture groups, highlighted in your text.

Your data stays in your browser. Nothing is uploaded to a server.

Flags

What is a regular expression?

A regular expression (regex) is a pattern that describes a set of strings. Developers use them to validate input, search logs, and extract pieces of text — for example, every number in a line or every email-like token in a file. This tester uses your browser's built-in JavaScript RegExp engine, so results match what you'll get in JavaScript and Node.js. Other engines (PCRE, Python, Java) differ in some details.

How to use the Regex Tester

Type the pattern without the surrounding slashes, pick the flags you need, paste your test string, and press Test (or Enter in the pattern field). You'll see whether it matched, how many matches there are, each match's text and index, and the value of every capture group. Up to 1,000 matches are shown.

JavaScript regex flags

  • g — global: find all matches instead of stopping at the first.
  • i — ignore case: a also matches A.
  • m — multiline: ^ and $ match at the start and end of each line.
  • s — dotAll: . also matches newline characters.
  • u — unicode: treats emoji and other astral characters as one character and enables \p{...} property escapes.

Example

The pattern \d+ with the g flag on the text Order 123, Order 456 finds 2 matches: 123 at index 6 and 456 at index 17. Wrapping part of a pattern in parentheses, like Order (\d+), captures just the number as group 1.

Named capture groups label each group. The pattern (?<year>\d{4})-(?<month>\d{2}) with the g flag on Released 2024-01, patched 2025-12 finds 2 matches: 2024-01 at index 9 (year 2024, month 01) and 2025-12 at index 26 (year 2025, month 12). The results list each group by number and name, e.g. Group 1 <year>.

FAQ

Is my text sent anywhere?

No. Patterns and test strings are evaluated entirely in your browser.

Why does my pattern show "Invalid regular expression"?

The pattern has a syntax error, such as an unclosed [ or (, or a quantifier with nothing to repeat. The message from the JavaScript engine points to the problem.

Why did my regex time out?

Some patterns take exponentially long on certain inputs — known as catastrophic backtracking. For example, (a+)+$ against a long run of a characters followed by ! can run for minutes. This tester evaluates every pattern in a Web Worker, separate from the page, and stops it after about 1.5 seconds with the message "Regular expression timed out. The pattern may cause excessive backtracking." Your tab stays responsive, and you can edit the pattern and test again. Nested quantifiers like (a+)+ are the usual cause.

Does it work in every browser?

It needs Web Worker support, which all current major browsers have. If Web Workers are unavailable, the tester shows an error instead of running the pattern, rather than risk freezing the page.