Regex Tester
Test and debug regular expressions with instant match results
Match Results
Match Details
Quick Templates
Replace Function
sed 's/pattern/replacement/g' input.txt
Regular Expression Testing Tool Documentation
Regular Expression Flags
g
i
m
Common Regular Expression Patterns - Quick Reference
Character Classes
\\d
Any digit (0-9)
\\D
Any non-digit character
\\w
Word character (a-z, A-Z, 0-9, _)
\\W
Any non-word character
\\s
Whitespace (space, tab, newline)
\\S
Any non-whitespace character
.
Any character except newline
[abc]
Any character in the set
[^abc]
Any character NOT in the set
Quantifiers
*
0 or more (greedy)
+
1 or more (greedy)
?
0 or 1 (optional)
{n}
Exactly n times
{n,}
n or more times
{n,m}
Between n and m times
*?
Lazy quantifier
Anchors & Boundaries
^
Start of line/string
$
End of line/string
\\b
Word boundary
\\B
Non-word boundary
Groups & Lookarounds (Advanced)
(abc)
Capturing group
(?:abc)
Non-capturing group
(?=abc)
Positive lookahead
(?!abc)
Negative lookahead
(?<=abc)
Positive lookbehind
(?<!abc)
Negative lookbehind
Special Characters (Must Be Escaped)
. * + ? ^ $ { } [ ] ( ) | \
Practical Examples
Email Address Validation
[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\\.[a-zA-Z]{2,}
Matches: one or more valid characters, followed by @, domain name, and 2+ letter extension.
Phone Number (US Format)
\\(?([0-9]{3})\\)?[-. ]?([0-9]{3})[-. ]?([0-9]{4})
Captures area code, exchange, and number with flexible formatting.
URL Matching
https?:\\/\\/(www\\.)?[-a-zA-Z0-9@:%._\\+~#=]{1,256}\\.[a-zA-Z0-9()]{1,6}\\b([-a-zA-Z0-9()@:%_\\+.~#?&//=]*)
Matches HTTP/HTTPS URLs with optional www prefix and various path formats.
Strong Password Validation
^(?=.*[a-z])(?=.*[A-Z])(?=.*\\d)[a-zA-Z\\d@$!%*?&]{8,}$
Requires at least 8 characters with lowercase, uppercase, and digit.
Advanced Features
([0-9]{4})-([0-9]{2})-([0-9]{2})
(?=.*password)
(?:http|https)://
Tips and Best Practices
- Start simple and build complexity gradually
- Use the global flag (g) to find all matches
- Escape special characters with backslash (\)
- Test thoroughly with various input examples
- Use capturing groups for complex replacements
- Consider performance with large texts
sed Command Generation
This tool automatically generates equivalent sed commands based on your regex pattern and replacement text, making it easy to use regex in Unix/Linux command line.
Search Mode (Empty Replacement)
When replacement text is empty, generates a search command to print matching lines only.
sed -n '/pattern/p' input.txt
errorReplace Mode (With Replacement)
When replacement text is provided, generates a substitution command.
sed 's/pattern/replacement/flags' input.txt
foo, Replace: barLearning Resources
Online Resources
Related Tools
Text Toolkit
Comprehensive text manipulation toolkit with word counter, data extraction, split/join, line filter, prefix/suffix operations
Text Diff Checker
Compare differences between two texts or files with side-by-side highlighted view
Case Converter
Text case conversion, supporting multiple formats
String Utilities
Comprehensive text processing toolkit with case conversion, find & replace, line operations and more