Skip to content

Free tool

Regex tester (JavaScript)

Write a regular expression and see every match and capture group highlighted live in your test text. Uses the JavaScript engine in your browser.

Pattern

//

JavaScript regular expressions (the same engine as Node.js and browsers). Flags: g, i, m, s, u, y, d.

2 matches

Call 555-1234 or 555-9876 today.

  1. #1 “555-1234” at 5 · groups: "555", "1234"
  2. #2 “555-9876” at 17 · groups: "555", "9876"

Flags

  • g global: find every match, not just the first.
  • i ignore case.
  • m multiline: ^ and $ match at line breaks.
  • s dotAll: . also matches newlines.
  • u Unicode: treat surrogate pairs as one character and allow \p{...} classes.
  • y sticky: match only at lastIndex.
  • d indices: return start and end positions of groups.

Avoid catastrophic backtracking

Patterns with nested quantifiers like (a+)+ or (.*)* can take exponential time on inputs that almost match. One such pattern in a firewall rule took a whole CDN down in 2019; see the Cloudflare outage explained. Prefer specific character classes over .*, anchor patterns, and limit input length before matching untrusted text.

Regex in monitoring

Keyword checks on uptime monitors, log-based alerts and log parsing all use regular expressions. Test them here against real log lines first: a pattern that never matches fails silently, and an alert that never fires is worse than none. See alerting best practices.

Using it safely at work

Online developer tools are a common way secrets leak: people paste production tokens, customer records or private keys into a website that quietly logs them. This page does all its work in your browser with standard Web APIs, makes no network request with your input, and stores nothing, so it is safe to use with real data, and you can confirm that in your browser’s network panel. Even so, treat anything you paste as you would treat a screenshot: rotate a token that was exposed, never share links that contain it, and prefer command-line tools on the server itself for very sensitive material.

Frequently asked questions

Is my data sent to a server?

No. This tool runs entirely in your browser; nothing you paste is uploaded or stored.

Which regex flavour is this?

JavaScript (ECMAScript), the same as browsers and Node.js. PCRE features like lookbehind are supported in modern browsers; possessive quantifiers are not.

Why does my pattern match empty strings?

Quantifiers like * allow zero characters; use + or anchor the pattern.

How do I match a literal dot?

Escape it: .

More free tools

All tools