Regex Tester
Test regular expressions with live match highlighting. Free, instant, private.
💻 Developer Tools
Free
Browser-based
/
/
What Is a Regular Expression?
A regular expression (regex) is a pattern that describes a set of strings. Instead of searching for one exact word, a regex lets you search for any string that matches a rule — for example, "any 10-digit number" or "any email address". Regex is supported in almost every programming language (JavaScript, Python, PHP, Java, Go) and in text editors like VS Code and Sublime Text. Mastering a few patterns lets you validate form inputs, extract data from logs, find-and-replace across files, and parse structured text with a single line of code.
Regex Flags
| Flag | Meaning | When to use |
|---|---|---|
g | Global — find all matches | Almost always; without it only the first match is returned |
i | Case-insensitive | When casing doesn't matter: hello matches Hello and HELLO |
m | Multiline — ^ and $ match line starts/ends | When testing patterns against multi-line input |
s | DotAll — . matches newlines too | When your target text spans multiple lines |
Regex Quick Reference
| Pattern | Matches |
|---|---|
. | Any character except newline |
\d | Digit (0–9) |
\w | Word character (a–z, A–Z, 0–9, _) |
\s | Whitespace (space, tab, newline) |
^ | Start of string / line |
$ | End of string / line |
* | 0 or more of the previous |
+ | 1 or more of the previous |
? | 0 or 1 of the previous (optional) |
{n,m} | Between n and m repetitions |
(abc) | Capture group |
(?:abc) | Non-capturing group |
a|b | a or b |
[abc] | Character class (a, b or c) |
[^abc] | Negated class (anything except a, b or c) |
Common Regex Patterns
| Use case | Pattern |
|---|---|
| Email address | [a-zA-Z0-9._%+\-]+@[a-zA-Z0-9.\-]+\.[a-zA-Z]{2,} |
| URL | https?://[^\s]+ |
| IPv4 address | \b\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}\b |
| Date YYYY-MM-DD | \d{4}-\d{2}-\d{2} |
| Hex color | #[0-9a-fA-F]{3,6} |
| Whole number | ^\d+$ |
| Slug (URL-safe) | ^[a-z0-9]+(?:-[a-z0-9]+)*$ |