Regular Expression Tester
Test your JavaScript regular expressions against any text and clearly highlight all matches and capture groups.
Loading tool...
Regular Expression Documentation
This tester uses the JavaScript regular expression engine of your browser (ECMAScript 2018+). Matches are computed locally, and results are updated while you type.
Character classes
| Pattern | Matches |
|---|---|
. |
Any character except line terminators |
\d / \D |
A digit / a non-digit |
\w / \W |
A word character / a non-word character |
\s / \S |
Whitespace / non-whitespace |
[abc] |
Any one of the listed characters |
[^abc] |
Any character that is not listed |
[a-z] |
Any character between a and z |
Quantifiers
| Pattern | Matches |
|---|---|
* |
Zero or more times |
+ |
One or more times |
? |
Zero or one time (optional) |
{n} |
Exactly n times |
{n,m} |
Between n and m times |
*? +? ?? |
Lazy (non-greedy) versions |
Groups and alternation
| Pattern | Matches |
|---|---|
(x) |
Capturing group |
(?:x) |
Non-capturing group |
| `x | y` |
\1 |
Back-reference |
Lookaround
| Pattern | Matches |
|---|---|
x(?=y) |
Positive lookahead |
x(?!y) |
Negative lookahead |
(?<=y)x |
Positive lookbehind |
(?<!y)x |
Negative lookbehind |
Flags
| Flag | Effect |
|---|---|
g |
Global: find every match |
i |
Case-insensitive matching |
m |
Multiline: ^ and $ match at line boundaries |
s |
Dot-all: . also matches line terminators |
u |
Unicode mode |
Common patterns
| Problem | Regular expression |
|---|---|
| Email address | ^[\w.+-]+@[\w-]+(\.[\w-]+)+$ |
| URL (http/https) | ^https?:\/\/[\w.-]+(?::\d+)?(?:\/[^\s?#]*)?(?:\?[^\s#]*)?(?:#\S*)?$ |
| IPv4 address | ^(?:(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)\.){3}(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)$ |
| Date YYYY-MM-DD | ^\d{4}-(0[1-9]|1[0-2])-(0[1-9]|[12]\d|3[01])$ |
| Hex color | ^#(?:[0-9a-f]{3}){1,2}$ |
| Strong password | ^(?=.*[a-z])(?=.*[A-Z])(?=.*\d)(?=.*[^\w\s]).{8,}$ |