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.

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.