Regex Tester & Debugger
Test and debug your regular expressions with real-time matching
Matches will be highlighted here...
How to Use
🔍 Test Patterns
Enter your regex pattern and test text to see matches in real-time. Matches are highlighted automatically.
⚙️ Configure Flags
Toggle regex flags like global, case-insensitive, multiline, and more to modify matching behavior.
💡 Use Cases
• Validate email addresses
• Extract URLs from text
• Find phone numbers
• Parse dates and formats
• Debug complex patterns
Anchors (Position)
| Character | Meaning | Example |
|---|
^ | Start of string/line | ^Hello matches "Hello" at start |
$ | End of string/line | world$ matches "world" at end |
\b | Word boundary | \bcat\b matches "cat" but not "category" |
\B | Not a word boundary | \Bcat\B matches "cat" inside words |
Character Classes
| Character | Meaning | Example |
|---|
. | Any character (except newline) | a.c matches "abc", "a1c" |
\d | Digit (0-9) | \d\d matches "12", "99" |
\D | Not a digit | \D\D matches "ab", "xy" |
\w | Word character (a-z, A-Z, 0-9, _) | \w+ matches "hello", "test123" |
\W | Not a word character | \W matches " ", "@", "!" |
\s | Whitespace (space, tab, newline) | \s+ matches spaces |
\S | Not whitespace | \S+ matches "hello" |
[abc] | Any of a, b, or c | [aeiou] matches vowels |
[^abc] | Not a, b, or c | [^0-9] matches non-digits |
[a-z] | Range: a to z | [0-9] matches digits |
Quantifiers (Repetition)
| Character | Meaning | Example |
|---|
* | Zero or more | a* matches "", "a", "aa" |
+ | One or more | a+ matches "a", "aa" (not "") |
? | Zero or one (optional) | colou?r matches "color", "colour" |
{n} | Exactly n times | \d{3} matches "123" |
{n,} | n or more times | \d{3,} matches "123", "1234" |
{n,m} | Between n and m times | \d{2,4} matches "12", "123", "1234" |
*? | Lazy (non-greedy) zero or more | a.*?b matches shortest "a...b" |
+? | Lazy (non-greedy) one or more | a.+?b matches shortest "a...b" |
Groups & Alternation
| Character | Meaning | Example |
|---|
(abc) | Capture group | (\\d{3}) captures "123" |
(?:abc) | Non-capturing group | (?:abc)+ groups without capturing |
a|b | Alternation (a or b) | cat|dog matches "cat" or "dog" |
\\1 | Backreference to group 1 | (\\w)\\1 matches "aa", "bb" |
Escaped Characters
| Character | Meaning | Example |
|---|
\\n | Newline | line\\n matches line with newline |
\\t | Tab | \\t matches tab character |
\\r | Carriage return | \\r\\n matches Windows line break |
\\. | Literal period | \\. matches "." (not any char) |
\\+ | Literal plus | \\+ matches "+" (not quantifier) |
\\* | Literal asterisk | \\* matches "*" (not quantifier) |
\\? | Literal question mark | \\? matches "?" (not quantifier) |
\\\\ | Literal backslash | \\\\ matches "\\" |
Common Patterns
| Pattern | Matches |
|---|
^[a-zA-Z]+$ | Only letters (no spaces/numbers) |
^\\d+$ | Only digits |
^[a-zA-Z0-9]+$ | Alphanumeric only |
^.{3,20}$ | 3 to 20 characters |
^[a-z0-9._%+-]+@[a-z0-9.-]+\\.[a-z]{2,}$ | Email address (basic) |
\\b\\d{3}-\\d{3}-\\d{4}\\b | Phone number (123-456-7890) |
https?://[\\w\\-]+(\\.[\\w\\-]+)+ | URL (http or https) |
💡 Quick Tips:
- Test incrementally: Start simple, add complexity gradually
- Use anchors:
^ and $ ensure full string matching - Escape special chars: Use
\\ before ., +, *, ? to match literally - Capture groups: Use
() to extract parts of matches - Non-greedy: Add
? after * or + for shortest match - Character classes:
[0-9] is same as \\d, [a-zA-Z] for letters