Test regular expressions in real-time with highlighted matches
A Regular Expression (Regex) is a mini-language for describing string matching patterns. It's used extensively for text search, data validation, and string replacement — virtually every programming language and text editor has a built-in regex engine.
| Pattern | Meaning | Pattern | Meaning |
|---|---|---|---|
. |
Any char (except newline) | ^ |
Start of string |
\d |
Digit [0-9] |
$ |
End of string |
\w |
[a-zA-Z0-9_] |
(abc) |
Capture group |
\s |
Whitespace | a|b |
a or b |
[abc] |
Character class | [^abc] |
Negated class |
* 0+ · + 1+ · ? 0 or 1 · {n} exactly n · {n,m} n to m
g global · i case-insensitive · m multiline (^$ match each line) · s dotAll (. matches newlines)
Email /^[\w.+-]+@[\w-]+\.[a-zA-Z]{2,}$/
Phone /^\+?[1-9]\d{7,14}$/
URL /^https?:\/\/[\w\-.]+(:\d+)?(\/\S*)?$/
This tool uses the JavaScript regex engine. If your pattern was written for Python, Java, or PCRE, some syntax (like (?P<name>...) named groups or \K lookbehind reset) may not be compatible. Use the JS syntax (?<name>...) instead.
By default, quantifiers (*, +, {n,m}) are greedy — they match as many characters as possible. Adding ? after a quantifier makes it non-greedy (lazy), matching as few characters as possible. For example, against <div>text</div>, <.*> matches the entire string, while <.*?> matches only <div>.
Use a backslash \ to escape them. Use \. to match a literal dot, \( for a parenthesis. Inside a character class [], most special characters lose their meaning, but ], \, ^ (at start), and - (in middle) still need escaping.