Regex Tester
Test regular expressions with live highlighting, named groups, replace and split, a plain-English explanation of the pattern, and protection from patterns that would freeze the page.
Runs in your browser. Nothing you add is uploaded.
What the Regex Tester does
Regular expressions are compact patterns for finding and validating text — an email address, a date, every number in a log — but a single misplaced character changes what they match. This tester runs your pattern against sample text as you type, highlights every match, lists each one with its position and its numbered and named capture groups, and previews replacements and splits. A line-by-line explanation says in plain English what each part of the pattern does. Patterns run in a background worker, so one that backtracks catastrophically is stopped after a moment instead of freezing the page. It uses your browser's own JavaScript regex engine, and includes ready patterns for common formats such as email, URLs, Indian mobile numbers, PIN codes, PAN, GSTIN and IFSC.
How to test a regular expression
- Type your pattern between the slashes, or start from one of the common patterns.
- Paste sample text: include text that should match and text that should not.
- Turn on the flags you need: g for every match, i to ignore case, m so ^ and $ work per line, s so . also matches line breaks, u for full Unicode.
- Check the highlighted matches, then switch to List to see each capture group, or to Replace and Split to try those operations.
- Read “What this pattern means” to check each part does what you intended, then copy the pattern as a JavaScript literal or new RegExp().
The Regex Tester runs entirely in your browser — nothing you enter is uploaded, stored, or logged.
When to use it
Validating form input
An Indian PIN code is six digits not starting with 0: ^[1-9][0-9]{5}$. Testing it against 560001, 056001 and 5600011 confirms it accepts the first and rejects the others before the pattern goes into your form.
Extracting data from logs
A pattern such as (\d{3}) (\d+)ms with the g flag pulls every status code and response time out of a pasted access log, with each part in its own capture group ready for your script.
Find and replace in an editor
VS Code and most editors support the same syntax. Getting the pattern and its groups right here first avoids a replace-all that rewrites the wrong lines.
Good to know
- Anchor validation patterns with ^ and $. Without them, [0-9]{6} also matches the first six digits of a ten-digit number.
- Quantifiers are greedy: <.+> matches from the first < to the last > on the line. Use <.+?> to stop at the nearest >.
- Escape characters that have special meaning when you want them literally: \. for a dot, \( for a bracket, \$ for a dollar sign.
- Patterns with nested repeats such as (a+)+ can take exponential time on long input. Keep repeats simple for anything that runs on user data.
- Other languages differ in details — lookbehind support, named-group syntax, Unicode classes — so re-test patterns that will run outside JavaScript.
Guides that use this tool
Frequently asked questions
Which regex engine does this tool use?
Why does my pattern only find the first match?
What is a capture group?
Is my test text sent anywhere?
Related tools
JSON Formatter
Format, validate and minify JSON with exact error locations.
URL Encoder & Decoder
Percent-encode text for URLs, or decode an encoded URL.
SQL Formatter
Format, beautify, and minify SQL queries for Postgres, MySQL, and SQLite.
JSON to YAML Converter
Convert bidirectional JSON to YAML and YAML to JSON with presets.