Online Regex Tester & Explainer
Interactive Regex Tester
Instantly test, debug, and learn regular expressions with this interactive regex tester. Enter your pattern, tweak flags, and see real-time match results. Perfect for validating user input, extracting data, or learning regex syntax—no sign-up, always free. Supports all major regex features and flags, with expert explanations and practical examples.
Regular Expression Pattern
/ /
Regex Flags:
Test Text
Results:
0 matches found
Enter a regex pattern and test text to see results…
Common Regex Patterns
Email Address
^[a-z0-9._%+-]+@[a-z0-9.-]+\.[a-z]{2,}$
URL
https?:\/\/(www\.)?[-a-zA-Z0-9@:%._+~#=]{2,256}\.[a-z]{2,6}\b([-a-zA-Z0-9@:%_+.~#?&//=]*)
US Phone
^\(?\d{3}\)?[- ]?\d{3}[- ]?\d{4}$
IPv4 Address
^((25[0-5]|2[0-4]\d|[01]?\d\d?)\.){3}(25[0-5]|2[0-4]\d|[01]?\d\d?)$
Digits Only
^\d+$
HTML Tags
<[^>]+>
Regex Reference Tables
Regex Flags Explained
Flag | Meaning | Example |
---|---|---|
i | Ignore case (A = a) | /abc/i matches “ABC” |
g | Global (find all matches) | /a/g finds every “a” |
m | Multiline (^/$ = line start/end) | /^abc/m matches at line start |
s | Dotall (dot matches newline) | /ab.c/s matches across lines |
u | Unicode (match Unicode chars) | /\w/u matches non-ASCII letters |
Regex Building Blocks
Element | Description | Example |
---|---|---|
. | Any character (except newline) | a.c matches “abc”, “a-c” |
^ | Start of string/line | ^abc matches “abc…” at start |
$ | End of string/line | xyz$ matches “…xyz” at end |
\d | Digit [0-9] | \d+ matches “2025” |
\w | Word char [a-zA-Z0-9_] | \w+ matches “hello_42” |
\s | Whitespace | \s+ matches spaces, tabs |
[abc] | Any of a, b, or c | [aeiou] matches vowels |
[^abc] | Not a, b, or c | [^0-9] non-digit |
* | 0 or more | \d* matches “”, “123” |
+ | 1 or more | \w+ matches “abc” |
? | 0 or 1 (optional) | colou?r matches “color”/”colour” |
{n} | Exactly n times | \d{3} matches “123” |
{n,} | At least n times | a{2,} matches “aa”, “aaa” |
{n,m} | Between n and m times | \d{2,4} matches “12”, “1234” |
Common Regex Pitfalls & Debugging Steps
Understanding common mistakes and debugging strategies will help you write better regular expressions and troubleshoot issues faster.
Greedy vs. Lazy Quantifiers
.*
matches as much as possible (greedy). Use .*?
for minimal (lazy) matching.
Escaping Special Characters
Characters like . ? * + ( ) [ ] { } \
must be escaped with \
to match them literally.
Global Matches
Forgetting the g
flag can cause only the first match to be found. Use g
to find all matches.
Multiline Mode
Use the m
flag if you want ^
and $
to match start/end of each line, not just the whole string.
Dot Doesn’t Match Newline
By default, .
does not match newlines. Use s
flag (dotall) to include newlines.
Debugging Workflow
1) Test with small samples 2) Add/remove flags 3) Use parentheses for clarity 4) Check error messages