Regex Tester
Test JavaScript regular expressions against any input. See matches, groups, and replacements live.
What are regular expressions and how do you read them?
Regular expressions (regex) are a tiny domain-specific language for matching patterns in text. Every modern programming language has a regex engine; this tool uses JavaScript's native RegExp, which follows the ECMAScript 2018+ specification and supports modern features like lookbehind assertions, named capture groups, Unicode property escapes, and the dotAll flag. The basic building blocks: literal characters match themselves (regex 'cat' matches the word cat); character classes match any one of a set ('[a-z]' matches lowercase letters); quantifiers control repetition (* zero or more, + one or more, ? zero or one, {3,5} between 3 and 5); anchors match positions (^ start of string, $ end, \b word boundary); groups capture submatches ((cat|dog) matches either, capturing which); alternation provides choice. Regex shines for parsing structured-but-not-grammatical text (logs, emails, phone numbers, simple HTML attributes) and falls apart for genuinely recursive structures (full HTML, nested JSON). For those, use a parser. This tester lets you iterate on a pattern with instant feedback — change the regex and the matches recompute on every keystroke.
Common use cases
Validate user input format (emails, phone numbers, postal codes) before sending to your server.
Extract structured data from log files (timestamps, IPs, status codes, request paths).
Find-and-replace across hundreds of files using your editor's regex search.
Write URL rewrite rules for Nginx, Apache .htaccess, or Vercel rewrites.
Parse simple CSV-like formats where a real parser is overkill.
Build form validation patterns for HTML <input pattern="..."> attributes.
Frequently asked questions
What flags are supported?▼
How do I match across multiple lines?▼
What's the difference between greedy and lazy quantifiers?▼
When should I NOT use regex?▼
What are named capture groups?▼
Why is my regex slow on certain inputs?▼
Does this match what my server-side regex engine does?▼
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.