Regex Tester
Test JavaScript regular expressions against any input and see every match, with its position, recompute live as you type.
How to use this tool
- 1
Type your regular expression into the pattern field (no slashes — enter the bare pattern).
- 2
Set the flags in the small field beside it, such as g, i, m, or a combination like gi.
- 3
Paste or type the text you want to search into the large input box below.
- 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?▼
Do I need the g flag?▼
Should I wrap my pattern in slashes?▼
What flags are supported?▼
Is my data sent anywhere?▼
Could a pattern hang the page?▼
Will matches here be identical on my server?▼
Related tools
JWT Decoder
Decode JSON Web Tokens (JWT) instantly — inspect the header, payload, and signature claims. Runs entirely in your browser; tokens never leave your device. Safe for production secrets.
JSON Formatter & Validator
Format, validate, and minify JSON instantly. Catches syntax errors with line numbers, pretty-prints with adjustable indent, supports large payloads. Runs in your browser — no upload.
XML Formatter & Beautifier
Format and beautify XML documents — proper indentation, line breaks, namespace handling. Useful for SOAP responses, sitemaps, RSS feeds, and Android resource files.
Base64 Encoder & Decoder
Encode and decode Base64 strings.
URL Encoder & Decoder
Encode/decode URL-safe strings.
HTML Entity Encoder & Decoder
Convert special characters to/from HTML entities.