Regex tester
Write and debug regular expressions with instant feedback. Type a pattern and some test text, and every match is highlighted as you type. The table lists each match with its position and capture groups, including named groups, and the replace box previews the result of a find-and-replace. It uses your browser's JavaScript regex engine, the same one used by Node.js and front-end code.
| # | Match | Position | Groups |
|---|
How to use the regex tester
- Type your pattern between the slashes. Don't add the slashes yourself.
- Tick the flags you need, or type them in the small box.
- Paste your test text. Matches are highlighted straight away.
- Check the matches table for positions and groups.
- Optional: type a replacement such as $2 $3 to preview a replace.
How it works
The pattern is compiled with JavaScript's RegExp and run over your text. Each match is highlighted, and the table shows its start and end position and any capture groups: $1, $2 and so on, or named groups written as (?<name>…).
Cheat sheet
| Pattern | Matches |
|---|---|
. | Any character except a new line |
\d \w \s | A digit, a word character, a space |
\D \W \S | Anything except those |
[abc] [^abc] [a-z] | One of, none of, a range |
^ $ | Start and end (of a line with the m flag) |
\b | A word boundary |
* + ? | 0 or more, 1 or more, 0 or 1 |
{3} {2,5} | Exactly 3, from 2 to 5 |
(…) (?:…) | A capture group, a group without capture |
(?=…) (?!…) | Followed by, not followed by |
A vertical bar means "or": cat|dog matches cat or dog.
Flags: g finds all matches, i ignores case, m makes ^ and $ work on each line, s lets the dot match new lines, and u turns on full Unicode support, including \p{L} for any letter in any language.
In the replacement, $1 inserts group 1, $& the whole match, and $<name> a named group.
Example
The sample pattern (\+91[- ]?)?\b([6-9]\d{4})[- ]?(\d{5})\b with the g flag finds Indian mobile numbers: 10 digits starting with 6, 7, 8 or 9, with or without +91, spaces or dashes. In the sample text it matches:
| # | Match | Groups |
|---|---|---|
| 1 | 98765 43210 | $2 = 98765, $3 = 43210 |
| 2 | +91-91234-56789 | $1 = +91-, $2 = 91234, $3 = 56789 |
| 3 | 9876543210 | $2 = 98765, $3 = 43210 |
The landline 080-41234567 is not matched. Replace with $2 $3 to write every mobile number the same way, such as 91234 56789.
Frequently asked questions
Which regex flavour does this tester use?
JavaScript (ECMAScript), using your browser's engine. It matches what you get in Chrome, Firefox, Node.js and most front-end code. Most patterns also work the same in Python, PHP and Java, but some advanced features differ.
Why does my pattern only find one match?
Add the g (global) flag. Without it, JavaScript stops after the first match.
How do I match a full stop or other special character?
Put a backslash before it: \. matches a real full stop, \( a bracket and \$ a dollar sign.
How do I match Hindi or other non-English letters?
Turn on the u flag and use \p{L} for any letter, or \p{Script=Devanagari} for Devanagari script only.
Last updated: 29 October 2026