RevealTheme logo

Regex Tester

Test JavaScript regular expressions against any input and see every match, with its position, recompute live as you type.

0 match(es)

How to use this tool

  1. 1

    Type your regular expression into the pattern field (no slashes — enter the bare pattern).

  2. 2

    Set the flags in the small field beside it, such as g, i, m, or a combination like gi.

  3. 3

    Paste or type the text you want to search into the large input box below.

  4. 4

    Read the match count and each matched substring with its character index in the results panel; an invalid pattern shows the engine's error message instead.

What are regular expressions and how does this tester evaluate them?

Regular expressions (regex) are a compact language for matching patterns in text. This tool compiles your pattern with JavaScript's native RegExp constructor — new RegExp(pattern, flags) — and runs input.matchAll() against your text, so it behaves exactly like regex in a browser or Node.js. That means it supports everything the V8/SpiderMonkey engine does: character classes ([a-z]), quantifiers (* + ? {3,5}), anchors (^ $ \b), alternation ((cat|dog)), lookahead and lookbehind, named groups, and Unicode property escapes. Two things are worth knowing about this specific UI. First, it lists only the full match text (group 0) and the index where each match starts — it does not display individual capture groups, named groups, or a replacement preview, even though the underlying matches contain that data. Second, because matchAll is used, you generally want the global g flag to see every match rather than just the first. The pattern field expects a raw pattern, not a /.../ literal, so don't wrap it in slashes. Regex is ideal for structured-but-flat text like logs, emails, and simple delimited formats, and a poor fit for recursive structures like HTML or JSON — reach for a parser there. Matches recompute on every keystroke for fast iteration.

Common use cases

  • Confirm a validation pattern (email, phone, postal code) matches the strings you expect before pasting it into server code.

  • Pull timestamps, IPs, or status codes out of a pasted log line and verify each match lands at the right position.

  • Prototype a find-and-replace search pattern, then copy it into your editor's regex search since this tool only shows matches, not replacements.

  • Draft and sanity-check URL rewrite patterns for Nginx, Apache .htaccess, or Vercel before deploying.

  • Debug why a regex matches too much or too little by watching the live match list as you tweak greedy vs. lazy quantifiers.

  • Build a pattern for an HTML <input pattern="..."> attribute and test sample values against it.

Frequently asked questions

Does this tool show capture groups or a replace preview?
No. The results panel lists only the full matched text (group 0) and the character index where each match begins. Named and numbered capture groups exist in the underlying RegExp result but are not displayed, and there is no replacement field. If you need to inspect groups or preview a replace, run the pattern in your editor or a Node REPL.
Do I need the g flag?
Usually yes. The tool uses input.matchAll(), which iterates all matches, and matchAll throws without the global flag in some engines and otherwise returns matches as expected — entering g makes the behavior predictable and lists every occurrence rather than stopping at the first.
Should I wrap my pattern in slashes?
No. The pattern field takes the raw expression and the flags go in the separate field. Type \d{3} in the pattern box and g in the flags box — not /\d{3}/g. Writing the slashes would make them literal characters in your pattern.
What flags are supported?
Whatever your browser's RegExp supports: g (global), i (case-insensitive), m (multiline — ^ and $ match at line breaks), s (dotAll — . matches newlines), u (unicode), and y (sticky). Combine them by concatenating, e.g. gim. An unsupported or duplicated flag makes the pattern invalid and the tool shows the error message.
Is my data sent anywhere?
No. The pattern, flags, and input text are evaluated entirely in your browser with the native RegExp engine. Nothing is uploaded to a server, so you can safely paste private logs or sample data.
Could a pattern hang the page?
Yes. JavaScript regex has no built-in timeout, so a pattern with catastrophic backtracking — nested quantifiers like (a+)+ against adversarial input — can freeze the tab. Avoid nested quantifiers, and for production validate patterns with a tool like the safe-regex npm package.
Will matches here be identical on my server?
Only if your server also runs JavaScript. This uses the ECMAScript regex flavor; PCRE, Python re, Ruby, and Java differ in lookbehind support, character-class semantics, and Unicode handling. Test in your target language before relying on parity.

Related tools