snaptxt.app

Regex Tester

Test JavaScript regular expressions with live match highlighting, capture group inspection, and a replace mode. Free, in your browser.

Pattern
//
Test text
3 matches
Drop us a line at hello@snaptxt.app, or hanuman@example.com. Old contact: support@old.co.uk Not an email: just-text-here.
Capture groups
#Match$1$2$3
1hello@snaptxt.apphellosnaptxtapp
2hanuman@example.comhanumanexamplecom
3support@old.co.uksupportold.couk

Your text and pattern stay on your device.

Matching uses the browser’s native JavaScript RegExp engine. Nothing is sent to a server.

How to use it

  1. 1Type your pattern between the / / slashes. Toggle flags below (g, i, m, s, u, y).
  2. 2Paste your test text on the left. Every match is highlighted in the panel on the right as you type — the count of matches updates live.
  3. 3If your pattern has capture groups, the table below the matches shows each group's value per match (numbered $1, $2 … and named groups too).
  4. 4Switch to Replace mode to test a substitution. Use $1, $2 for capture groups, $& for the whole match, and $<name> for named groups.
  5. 5On Chrome with the Prompt API enabled, describe what to match in plain English and on-device Gemini Nano writes the regex — or hit Explain to get a Gemini Nano breakdown of what your current pattern does.

Common use cases

  • Sanity-check a regex before pasting it into a codebase or config file.
  • Extract emails, IDs, or URLs out of a chunk of unstructured text using capture groups.
  • Rehearse a search-and-replace before running it on a real document.
  • Teach or learn regex by watching the highlights update with every keystroke.
  • Diagnose why a pattern is matching too much (or too little) with the live match count.
  • Skip the regex memorization — describe what to match in English and let on-device AI write it.

Frequently asked questions

Can the AI write a regex from a description?
Yes — on Chrome with the Prompt API enabled, a panel above the pattern lets you type something like "match a US phone number with optional country code" and Gemini Nano writes the regex on-device. The /pattern/flags literal is parsed out of the response and loaded straight into the pattern field so you can test it immediately. The whole exchange happens on your machine; nothing is sent to a remote service.
How does the Explain button work?
It feeds your current pattern (plus a few sample matches from the test text) to Chrome's on-device Gemini Nano and streams back a 3–6 sentence plain-English description: what it matches, the role of each token, and any backtracking or unicode pitfalls. Only visible on browsers that support the Prompt API.
Which regex flavor is this?
ECMAScript / JavaScript regex — the same engine that runs in browsers and Node.js. It's close to PCRE but with a few differences: no possessive quantifiers, no atomic groups, look-behind is supported in modern browsers.
Is my pattern or test text sent anywhere?
No. The page uses the browser's built-in RegExp engine. Nothing is uploaded.
What do the flags do?
g (global) finds every match instead of just the first. i (case-insensitive). m (multiline) makes ^ and $ match at line breaks. s (dotall) makes . match newlines. u (unicode) enables full Unicode escapes like \p{...}. y (sticky) only matches starting at lastIndex — rarely used outside parsers.
Why is my regex matching too many things?
Usually because of greedy quantifiers (* and + match as much as possible). Use the lazy form (*? and +?) to stop at the first satisfying match. Anchors (^, $, \b) also help by tying the pattern to a specific position.
Capture group $1 is empty — why?
If your regex contains an alternation (a|b), only the branch that actually matched will fill its groups. Branches that didn't match return undefined for their groups. Either restructure the pattern, or check the named group instead.
Is there a match limit?
The page caps at 5,000 matches per pattern to keep the UI responsive. If you're seeing the cap, narrow your pattern.

Related tools

Base64 Encode / Decode
Encode and decode text and files to and from Base64.
HTML Live Preview
Write HTML, CSS, and JavaScript and see the result instantly.
JSON Formatter
Format, validate, minify, diff, and explore JSON — with optional on-device AI that summarizes any payload in plain English.
JWT Decoder
Inspect the header, payload, and expiry of any JSON Web Token — with optional on-device AI that explains what the token grants in plain English.
SQL Formatter
Beautify, format, and minify SQL queries for any dialect — with optional on-device AI that explains what a query does in plain English.
Unix Timestamp Converter
Convert Unix timestamps to dates and back, in any timezone.
Hash Generator
Generate MD5, SHA-1, SHA-256, and SHA-512 hashes in your browser.
JSON to TypeScript
Generate TypeScript interfaces or type aliases from JSON.
Markdown to PDF
Convert Markdown to a beautifully styled PDF in your browser.
QR Code Generator
Make QR codes for websites, Wi-Fi passwords, contact cards, social handles, email, SMS, and more. Download as PNG or SVG — or as a ZIP with one branded QR per social platform.
Password Generator
Generate strong, secure passwords in your browser. Nothing is sent or saved to any server.
Text Diff
Compare two pieces of text and see line-by-line, word-by-word, or character-by-character what changed.
UUID / ULID Generator
Generate UUID v4, UUID v7, or ULID identifiers in bulk, instantly in your browser.
SVG to PNG / JPEG / WebP
Convert SVG to PNG, JPEG, or WebP at any size — quality slider, transparent or colored background, copy to clipboard. Free, in your browser.
URL Encoder / Decoder
Encode or decode URLs and query parameters with component-vs-full-URI scope, plus a query-string breakdown. Free, in your browser.
Color Converter
Convert colors between HEX, RGB, HSL, HSV, and OKLCH, and generate tint, shade, and harmony palettes. Free, in your browser.
HTML ↔ Markdown Converter
Convert HTML to Markdown or Markdown to HTML with a live preview. GFM tables, fenced code blocks, inline formatting. Free, in your browser.
Cron Builder
Build cron expressions visually or describe the schedule in plain English and let on-device AI write it for you. Plain-English explanation, next 5 runs, presets.