How to use the regex tester
- Type your pattern between the slashes and choose flags.
- Paste test text. Every match is highlighted as you type, and the table lists each match with its capture groups and position.
- Enter a replacement to preview the result of a find-and-replace, using
$1,$2… for captured groups or$&for the whole match.
The tester uses your browser’s JavaScript regex engine, so results match exactly what String.match() and String.replace() do in Node.js and the browser. Most syntax is shared with Python, PHP (PCRE) and Java, but some advanced features differ.
Flags
| Flag | Meaning |
|---|---|
g | Global — find all matches, not just the first |
i | Case-insensitive |
m | Multiline — ^ and $ match at the start and end of each line |
s | Dot-all — . also matches line breaks |
u | Unicode — enables \p{…} property escapes and correct handling of emoji |
y | Sticky — match only at the current position |
Regex cheat sheet
| Pattern | Matches |
|---|---|
. | Any character except a line break |
\d / \D | A digit / not a digit |
\w / \W | A word character (letter, digit, underscore) / not one |
\s / \S | Whitespace / not whitespace |
[abc] / [^abc] | Any of a, b, c / anything except them |
^ / $ | Start / end of the string (or line with m) |
* + ? | 0 or more, 1 or more, 0 or 1 |
{3} {2,5} | Exactly 3, between 2 and 5 |
*? +? | Lazy versions — match as little as possible |
(…) / (?:…) | Capture group / non-capturing group |
(?<name>…) | Named capture group |
a|b | a or b |
(?=…) / (?!…) | Lookahead / negative lookahead |
\b | Word boundary |
Useful patterns
- Bangladesh mobile number:
^(?:\+?88)?01[3-9]\d{8}$ - Simple email check:
^[^\s@]+@[^\s@]+\.[^\s@]+$ - Date YYYY-MM-DD:
^\d{4}-(0[1-9]|1[0-2])-(0[1-9]|[12]\d|3[01])$ - Hex colour:
^#?([0-9a-f]{3}|[0-9a-f]{6})$with theiflag - Extra spaces:
{2,}— replace with a single space
Real-world validation (especially for email addresses) is more complex than any short regex. Use patterns like these for quick checks, and rely on proper validation on the server.
Frequently asked questions
Which regex flavour does this tester use?
JavaScript (ECMAScript), as implemented by your browser. It matches Node.js behaviour exactly and is very close to PCRE, Python and Java for common patterns.
Why does my pattern only find one match?
Add the g (global) flag to find every match.
How do I match a literal dot or bracket?
Escape it with a backslash: \. matches a dot, \( matches an opening bracket.
Is my text sent anywhere?
No. Matching happens in your browser.