Regex Tester
Free online tool to test regular expression patterns and see matching results in real-time.
//
Flags
- g - Global: Find all matches
- i - Case insensitive
- m - Multiline: ^ and $ match line breaks
- s - Dotall: . matches newlines
- u - Unicode: Full unicode support
Common Syntax
.- Any character\d- Digit (0-9)\w- Word character (a-z, A-Z, 0-9, _)\s- Whitespace*- 0 or more+- 1 or more?- 0 or 1[abc]- Any of a, b, or c(abc)- Capture group
Key Features
- Real-time Matching: See results instantly as you type
- 5 Flags: Support for g, i, m, s, u flags
- Highlight Display: Visual highlighting of matched portions
- Group Capture: Detailed capture group information
- Common Patterns: Pre-built frequently used patterns
- Position Info: Start/end position display for each match
Flag Descriptions
| Flag | Name | Description |
|---|---|---|
| g | Global | Find all matches (not just first) |
| i | Ignore Case | Case-insensitive matching |
| m | Multiline | ^ and $ match start/end of each line |
| s | Dotall | . matches newlines too |
| u | Unicode | Full Unicode support |
Common Pattern Examples
Email
\w+@\w+\.\w+
Matches: user@example.com, admin@test.org
URL
https?://[\w\-._~:/?#\[\]@!$&'()*+,;=]+
Matches: http://example.com, https://site.com/page
Phone Number
\+?\d{1,4}?[-.\s]?\(?\d{1,3}?\)?[-.\s]?\d{1,4}[-.\s]?\d{1,4}[-.\s]?\d{1,9}
Matches: 010-1234-5678, +82-10-1234-5678
Hex Color
#[0-9a-fA-F]{6}|#[0-9a-fA-F]{3}
Matches: #FF5733, #f00
Date (YYYY-MM-DD)
\d{4}-\d{2}-\d{2}
Matches: 2024-01-15
IP Address
\b(?:\d{1,3}\.){3}\d{1,3}\b
Matches: 192.168.0.1
Capture Groups
Basic Groups
Pattern: (\d{4})-(\d{2})-(\d{2})
Text: 2024-01-15
Group 1: 2024
Group 2: 01
Group 3: 15
Named Groups
Pattern: (?<year>\d{4})-(?<month>\d{2})-(?<day>\d{2})
Text: 2024-01-15
Group year: 2024
Group month: 01
Group day: 15
Practical Examples
Extract HTML Tags
<(\w+)[^>]*>
Text:
<div class="box">Content</div>
<p>Paragraph</p>
Matches: div, p
Variable Name Validation
^[a-zA-Z_$][a-zA-Z0-9_$]*$
Valid: myVar, _temp, $value Invalid: 123abc, my-var
Extract Numbers
-?\d+\.?\d*
Matches: 123, -45, 67.89, -0.5
Word Boundary
\bcat\b
Text: "cat category catch" Matches: cat (first one only)
Advanced Patterns
Lookahead
# Positive lookahead
\d+(?= won)
Text: "100 won, 200 dollars"
Matches: 100
# Negative lookahead
\d+(?! won)
Text: "100 won, 200 dollars"
Matches: 200
Lookbehind
# Positive lookbehind
(?<=\$)\d+
Text: "$100, 200 won"
Matches: 100
# Negative lookbehind
(?<!\$)\d+
Text: "$100, 200 won"
Matches: 200
Non-greedy Matching
# Greedy
<.*>
Text: "<div>test</div>"
Matches: <div>test</div> (entire string)
# Non-greedy
<.*?>
Text: "<div>test</div>"
Matches: <div>, </div> (separately)
Performance Tips
1. Use Specific Patterns
# Slow
.*
# Fast
[a-z]+
2. Use Anchors
# Slow
\d{4}-\d{2}-\d{2}
# Fast
^\d{4}-\d{2}-\d{2}$
3. Non-capturing Groups
# Capturing (slower)
(\d+)
# Non-capturing (faster)
(?:\d+)
Common Mistakes
1. Literal . Character
# Wrong: . matches any character
example.com
# Correct: escape with \.
example\.com
2. Confusing * and +
# *: 0 or more (may not match)
ab*c → ac, abc, abbc
# +: 1 or more (must match)
ab+c → abc, abbc (ac doesn't match)
3. Group Numbers
Pattern: (\d+)-(\d+)
Text: 123-456
Group 0: 123-456 (full match)
Group 1: 123
Group 2: 456
Debugging Tips
- Step-by-step Testing: Break complex patterns into smaller parts for testing
- Check Flags: Verify desired flags are enabled
- Escape: Add
\before special characters - Online Tools: Cross-check with multiple regex testers
🔗 Try These Next
- Find and Replace - Replace text using regex
- Text Comparison - Compare text differences
- Case Converter - Convert text case
💬 Was this tool helpful?
Feel free to send us your feedback or suggestions anytime!
Privacy
This tool operates entirely on the client side. Your patterns and text are never sent to a server and are processed only in your browser.