Regex Tester
Test regular expressions with live matching, replace mode, code generation, and more.
Regular Expression
Pattern Explanation
Common Patterns
Regex Cheat Sheet
Test String
Highlighted Matches
Match Details
Test String
Replace With
Replace Result
Diff View
Generate Code
Regex cheat sheet — the syntax you actually need
Regex looks cryptic until you recognize the building blocks. Keep this open while writing expressions:
| Symbol | Meaning | Example |
|---|---|---|
. | Any character except newline | a.c matches "abc", "a1c" |
\d | Any digit (0-9) | \d+ matches "123" |
\w | Word character (a-z, A-Z, 0-9, _) | \w+ matches identifiers |
\s | Whitespace (space, tab, newline) | \s+ collapses multiple spaces |
^ | Start of line / string | ^Hello |
$ | End of line / string | world$ |
* | 0 or more (greedy) | a* |
+ | 1 or more (greedy) | a+ |
? | 0 or 1 (optional) | colou?r matches color or colour |
*?, +? | Non-greedy (lazy) | <.*?> matches single HTML tag |
{n,m} | Between n and m repetitions | \d{3,5} |
[abc] | Any one of a, b, c | [aeiou] |
[^abc] | Not a, b, or c | [^0-9] |
(abc) | Capture group | (\d+)-(\d+) |
(?:abc) | Non-capturing group | |
| | Alternation (OR) | cat|dog |
\b | Word boundary | \bcat\b doesn't match "category" |
Common regex patterns — email, URL, phone, date
Copy-ready patterns for everyday validation. None are perfectly correct (email validation in particular is infamously hard) but these cover 99%+ of real input:
# Email (reasonable, not RFC 5322 compliant — nobody's is)
^[\w.+-]+@[\w-]+\.[\w.-]+$
# URL (http/https)
^https?://[\w\-.]+(\.\w+)+(/\S*)?$
# International phone (E.164)
^\+?[1-9]\d{1,14}$
# US phone
^\(?\d{3}\)?[-. ]?\d{3}[-. ]?\d{4}$
# Indian phone (+91, 10 digits)
^(\+91|91)?[6-9]\d{9}$
# Date YYYY-MM-DD
^\d{4}-(0[1-9]|1[0-2])-(0[1-9]|[12]\d|3[01])$
# IPv4 address
^((25[0-5]|2[0-4]\d|[01]?\d\d?)\.){3}(25[0-5]|2[0-4]\d|[01]?\d\d?)$
# UUID v4
^[0-9a-f]{8}-[0-9a-f]{4}-4[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$
# Strip HTML tags
<[^>]+>
# Whitespace (collapse multiple → one)
\s+
Regex engines differ — JavaScript vs Python vs PCRE
The same regex can behave differently across languages. Mostly minor but catches people off guard:
- JavaScript — no lookbehind (
(?<=...)) until ES2018; limited Unicode support without/uflag. - Python
re— no possessive quantifiers (a++), uses(?P<name>...)for named groups (vs(?<name>...)elsewhere). - PCRE (PHP, nginx) — most powerful, supports everything including recursion and conditional patterns.
- Java
java.util.regex— strict backslash escaping in source code.\\din a Java string literal. - Go
regexp— RE2 engine, no backreferences or lookaround. Fast + safe but less expressive. - Rust
regex— also RE2-style, guaranteed linear time. - grep BRE — basic regex.
+?|()all need backslash escaping. Usegrep -Efor extended.
Our tester uses the JavaScript engine in your browser — same one as your production code if you're targeting Node or browsers. If you need PCRE or Python semantics specifically, mirror the pattern to regex101.com and select the corresponding flavor.
Frequently Asked Questions
What is a regular expression?
A regular expression (regex) is a sequence of characters that defines a search pattern, used for string matching, validation, and text manipulation.
What do regex flags mean?
g (global) finds all matches, i (case insensitive) ignores case, m (multiline) makes ^ and $ match line boundaries, s (dotall) makes . match newlines.
How do capture groups work?
Parentheses () create capture groups that extract specific parts of a match. Reference them with $1, $2, etc. in replacements.
Related Developer Tools
Copyright © 2026 BuildStudio. All rights reserved.
Designed and Developed by Webority Technologies