/.*/ Regex Tester
A regex tester that highlights matches the moment you type. JavaScript (ECMAScript) syntax, with groups, replace preview and a cheat sheet.
How to use the regex tester
- Type your pattern between the
/ … /slashes. You don't need to type the slashes yourself. - Toggle the flags
gimsuat the top (gis on by default). - Paste text into test string. Matches are highlighted in the highlight panel and the match count appears in its top-right corner.
- The matches & groups table lists each match with its position (
@index), numbered groups$1,$2… and named groups<name>. - Type a replacement in replace to preview the result of
String.prototype.replacelive. - Click any cheat-sheet entry to insert it at the cursor. sample loads an email-extraction example with named groups.
What is a regular expression?
A regular expression (regex) is a compact pattern that describes "strings that look like this." Developers use regex to validate input formats (emails, ZIP codes, phone numbers), pull specific lines out of logs, and run bulk find-and-replace in editors like VS Code. This tester uses your browser's own RegExp engine, so it follows JavaScript (ECMAScript) syntax — the same flavor used in Node.js, TypeScript and most front-end code. Python, Java, PCRE and .NET are very similar but differ in a few details (see the FAQ).
Regex flags
| Flag | Name | What it does |
|---|---|---|
g | global | Find all matches (off = stop after the first) |
i | ignore case | Case-insensitive matching |
m | multiline | ^ and $ match at the start/end of every line |
s | dotAll | . also matches line breaks |
u | unicode | Treats emoji and other astral characters as one character; enables \p{…} property escapes |
Common regex patterns
| Goal | Pattern | Notes |
|---|---|---|
| US phone number | \(?\d{3}\)?[-.\s]?\d{3}[-.\s]?\d{4} | Matches (555) 123-4567, 555.123.4567, 5551234567 |
| US ZIP code | ^\d{5}(-\d{4})?$ | 12345 or ZIP+4 12345-6789 |
| Simple email | ^[^\s@]+@[^\s@]+\.[^\s@]+$ | Loose on purpose — confirm with a verification email |
| Collapse spaces | \s{2,} → " " | Turns runs of whitespace into one space |
| Reorder a date | (\d{4})-(\d{2})-(\d{2}) → $2/$3/$1 | 2026-10-13 → 10/13/2026 |
| Hex color | #(?:[0-9a-fA-F]{3}){1,2}\b | #fff or #C6FF3D |
In the replacement you can use $1 (numbered group), $<name> (named group) and $& (the whole match). The copy button next to the pattern copies a /pattern/flags literal you can paste straight into JavaScript; the copy button on the replace panel copies the full replaced text. If the pattern is invalid, the browser's error message appears in red under it.
Tips
*and+are greedy:<.*>grabs from the first<to the last>. Add?(<.*?>) for the shortest match.- Anchor validation patterns with
^…$, otherwise\d{5}happily "validates"abc123456xyz. - Escape special characters with a backslash:
\.\(\$\?. Inside a character class most of them are literal:[.$].
The table shows up to 200 matches and the counter stops at 5,000. Patterns that match an empty string (like a*) are counted but not highlighted. Nested quantifiers such as (a+)+ can cause catastrophic backtracking (ReDoS) and freeze the tab on long input. Your text never leaves the browser.