Regular expressions (regex) are powerful but notoriously hard to write correctly. This guide explains how to test regex patterns online and covers the most useful syntax.
โก Try It Free โ No Signup
Works instantly in your browser. No account, no install, no upload.
Open Regex Tester โRegular Expression Basics
A regular expression is a sequence of characters that defines a search pattern. Used for validating input, finding text, extracting data, and replacing strings.
Essential Regex Syntax
| Pattern | Meaning | Example |
|---|---|---|
| . | Any character | a.c โ "abc", "a1c" |
| * | 0 or more | ab* โ "a", "ab", "abb" |
| + | 1 or more | ab+ โ "ab", "abb" |
| ? | 0 or 1 | colou?r โ "color", "colour" |
| \d | Any digit | \d+ โ "123" |
| \w | Word character | \w+ โ "hello" |
| ^ | Start of string | ^Hello |
| $ | End of string | world$ |
Common Regex Patterns
# Email validation
^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}$
# URL
https?://[^\s/$.?#].[^\s]*
# Phone number (US)
\+?1?\s?\(?\d{3}\)?[\s.-]\d{3}[\s.-]\d{4}
# IPv4 address
(?:\d{1,3}\.){3}\d{1,3}
# Hex color
#([A-Fa-f0-9]{6}|[A-Fa-f0-9]{3})
Regex Flags
gโ Global: find all matches (not just the first)iโ Case-insensitivemโ Multiline: ^ and $ match line boundariessโ Dot-all: . matches newlines
Frequently Asked Questions
What regex flavor does the tester use?
JavaScript (ECMAScript) regex, which is the same engine used in all modern browsers and Node.js.
How do I match a literal dot?
Escape it with a backslash:
\. matches a literal dot. Without the backslash, . matches any character.What are capture groups?
Parentheses
() create capture groups that extract specific parts of a match. For example, (\d{4})-(\d{2})-(\d{2}) on a date string captures year, month, and day separately.Why does my regex work in Python but not JavaScript?
Different languages use slightly different regex flavors. Python supports lookbehind with variable length; JavaScript doesn't (pre-ES2018). Always test in the environment you'll use.