← Back to all tools

🔍 Regex Tester

Test regular expressions in real-time with live match highlighting.

💡 Quick Reference

📚 How Regex Tester Works

Regular expressions (regex) are patterns used to match character combinations in strings. This tool tests your regex patterns in real-time, shows all matches, and explains what each part means.

🎯 Common Use Cases

💡 Regex Flags Explained

g (global)

Find all matches, not just the first one

/cat/g matches "cat" and "cat" in "cat dog cat"
i (case-insensitive)

Ignore case when matching

/cat/i matches "Cat", "CAT", "cat"
m (multiline)

^ and $ match start/end of each line

/^dog/m matches "dog" at start of any line

📖 Pattern Examples

Match an email address:
Pattern: /^[\w.-]+@[\w.-]+\.\w{2,}$/
Test: [email protected] ✓
Test: invalid@email ✗
Extract all numbers from text:
Pattern: /\d+/g
Test: "I have 3 cats and 12 dogs"
Matches: ["3", "12"]

❓ FAQ

What does \d, \w, \s mean?

\d = any digit (0-9)
\w = any word character (a-z, A-Z, 0-9, _)
\s = any whitespace (space, tab, newline)
Uppercase negates: \D = NOT a digit

How do I match a literal dot or bracket?

Escape special characters with backslash \
• Literal dot: \. (instead of . which means "any char")
• Literal bracket: \[ or \]
• Literal backslash: \\

What's the difference between + and *?

+ = one or more (at least 1)
* = zero or more (can be empty)
? = zero or one (optional)
Example: colou?r matches "color" and "colour"

🔧 Using Regex in Code

JavaScript Example:
// Test if string matches pattern
const isEmail = /^[\w.-]+@[\w.-]+\.\w+$/.test(email);

// Find all matches
const numbers = text.match(/\d+/g);

// Replace with regex
const cleaned = text.replace(/\s+/g, ' ');