Open tools · 0

About

Regex Tester

Write a JavaScript regular expression and every match lights up in the test text as you type, with its capture groups listed underneath. The pattern is explained in plain English, piece by piece, and one that backtracks catastrophically is stopped after a second and a half instead of freezing the tab.

What it does

  • Matches highlighted in the text, each with its position and every numbered and named capture group.
  • Flags g, i, m, s, u, v, y and d, each with a note on what it does.
  • Replace: the text after a substitution with $1, $<name>, $&, $` and $'.
  • List: one line per match from a template, which is how a column is pulled out of a log.
  • Explain: the pattern broken into its pieces in plain English.
  • A quick reference that inserts any token with a click.
  • A dozen ready patterns, from email addresses and URLs to dates, UUIDs and version numbers, each with sample text.
  • Copy the pattern as a JavaScript snippet.

How to use it

  1. Type the pattern, or paste a literal like /abc/gi and it splits into pattern and flags.
  2. Paste the text to test against; the matches light up as you type.
  3. Open Replace or List for a substitution or an extract, or Explain to read the pattern.
  4. Copy the JavaScript.

What it does not do

  • Other flavours (PCRE, Python, Go, .NET): the browser runs only its own engine, and a PCRE port in WebAssembly is a weight this site does not load.
  • A saved suite of tests for a pattern: there are no accounts here to keep it in.
  • Links to a pattern: the address carries the window, not what is in it, so a pattern is shared by copying the snippet.

Questions

Which regex engine is this?

The browser’s own JavaScript engine, so what matches here matches in Node and in every current browser. Python’s re and PCRE differ in lookbehind, possessive quantifiers and Unicode classes.

What is the v flag?

Unicode sets, added in ES2024: set operations and string properties inside [...], with stricter syntax than u.

Why did my pattern stop?

It ran for more than 1.5 seconds, which is catastrophic backtracking: nested quantifiers such as (a+)+ over text that nearly matches. Explain shows the nesting; rewriting it so each character can match only one way fixes it.

How do I refer to a named group in Replace?

With $<name>. Numbered groups are $1, $2 and so on, and $& is the whole match.

Everything here runs in your browser. Nothing you type, paste or open is uploaded, and there is no account and no queue. How that works.

Often used with

More in Dev Tools

  • JSON Formatter: Format, validate, repair and explore JSON: tree view, sorted keys, and big numbers kept exactly.
  • Hash Generator: Hash text or files with MD5, SHA-1, SHA-2, SHA-3, BLAKE3, CRC-32 and more; verify a checksum; compute an HMAC.
  • Unix Timestamp Converter: Turn Unix timestamps in seconds, milliseconds or nanoseconds into dates and back, many at once, with Excel, Windows and Discord times too.
  • JWT Decoder: Decode a JSON Web Token, read every claim and its dates, and verify the signature with a secret, a PEM or a key set, told why when it fails.
  • URL Encode & Decode: Percent-encode or decode text for a URL with the kinds of escaping told apart, and take a link apart: edit its query, strip its tracking, see its real host.

All toolsAbout utilbrewPrivacy