Regex Tester
Test a regular expression against your text and see every match and capture group highlighted, right in your browser.
Quick reference
. any character\d digit\w word character\s whitespace[abc] one of a, b, c[^abc] not a, b, c[a-z] range\b word boundary^ start of line$ end of linea* 0 or morea+ 1 or morea? 0 or 1a{2,5} 2 to 5 timesa+? lazy (as few as possible)a|b a or b(abc) capture group(?<name>abc) named group(?:abc) non-capturing(?=abc) followed byg all matchesi ignore casem ^ $ per lines . matches newlineSuggested tools
About Regex Tester
Regex Tester lets you build and debug regular expressions against your own text, with every match highlighted as you type, capture groups and named groups listed, and a replacement preview using $1 or $<name>. It uses JavaScript's regex engine with the g, i, m, s, u and y flags.
Patterns run in a separate worker with a time limit, so a runaway pattern (catastrophic backtracking) is stopped instead of freezing the page. A quick-reference panel lists the most-used syntax. It runs entirely in your browser, so nothing you paste is uploaded.
How to use Regex Tester
- Type your pattern and choose flags.
- Paste the test text — matches are highlighted live.
- Optionally enter a replacement to preview the result.
Key features
- Live highlighting of every match
- Capture and named groups listed
- Replacement preview with $1 / $<name>
- Protection against runaway patterns
Example
Pattern [6-9]\d{9} with the g flag — a 10-digit Indian mobile number starting with 6, 7, 8 or 9.
Call 9876543210 or 8123456789. Old number: 12345.
Match 1: 9876543210 (position 5) Match 2: 8123456789 (position 19)
When to use Regex Tester
- Building a validation pattern for phone numbers, PIN codes or IDs.
- Testing a search-and-replace before running it on many files.
- Extracting values such as order numbers from logs.
Tips and common problems
- Add the g flag to see every match, and m when ^ and $ should work per line.
- Use ^ and $ to match the whole value when validating input.
- Avoid nested quantifiers such as (a+)+ — they can run for a very long time.
Frequently asked questions
Most common syntax is the same, but details differ (lookbehind support, named-group syntax, flags). Test in your target language before shipping.
Turn on the g (global) flag to find all matches.
The pattern backtracks exponentially on this input. Make quantifiers more specific or avoid nested ones like (a+)+.
Guides
- Regex Patterns for Indian Phone Numbers, PIN, PAN, GSTIN and IFSC — Ready-to-use regex for Indian mobile numbers, PIN codes, PAN, GSTIN, IFSC and more, explained part by part, with the limits of what a pattern can check.
- Cron Expressions Explained (with Examples) — The five fields of a cron expression, the special characters * , - and /, schedules you can copy, and time-zone mistakes that make jobs run at the wrong hour.