Regular Expression Tester
Real-time regex testing, highlighted match results, common pattern library and replace function
Match Results
No matches yet
Replace Function
Common Pattern Library
Usage Guide
Regex Flags
- g - Global: Find all matches, not just the first
- i - Case insensitive: Matching is case-insensitive
- m - Multiline: ^ and $ match the start and end of each line
Capture Groups
Use parentheses () to create capture groups, which can be referenced in replacements using $1, $2, etc.
Example: (\d{3})-(\d{4}) matches 123-4567, replace with $2-$1 to get 4567-123
Common Metacharacters
\d- Digit (0-9)\w- Word character (alphanumeric + underscore)\s- Whitespace character.- Any character (except newline)*- 0 or more times+- 1 or more times?- 0 or 1 time
Real-time Matching
After entering the regex pattern and test text, the tool displays match results in real-time with highlighted matches for easy debugging and learning.
Regex Testing Guide
Email Validation
^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}$
Validates email format accurately. Test various inputs to ensure correctness.
Phone Number Extraction
1[3-9]\d{9}
Extract phone numbers from text. Use with 'g' flag to find all matches.
Password Strength
^(?=.*[a-z])(?=.*[A-Z])(?=.*\d)(?=.*[@$!%*?&])[A-Za-z\d@$!%*?&]{8,20}$
Requires: lowercase, uppercase, digit, special char, 8-20 length.
Log Parsing
^\[.*?\]\s+ERROR.*$
Extract ERROR logs from server logs. Use 'g' and 'm' flags for multiline.
FAQ
What are g, i, m flags?
g: Global (all matches). i: Ignore case. m: Multiline (^ $ match line starts/ends).
How to escape special characters?
Use backslash: \. \* \+ \? \^ \$ \{ \} \[ \] \( \) \| \\
Greedy vs non-greedy?
Greedy (.+): Matches as much as possible. Non-greedy (.+?): Matches as little as possible. Add ? after quantifier for non-greedy.
How to match Chinese characters?
Use [\u4e00-\u9fa5]+ to match one or more Chinese characters.
🔒 Technology & Privacy
Technology
- • JavaScript RegExp engine
- • Real-time matching
- • Syntax highlighting
- • Error detection
Privacy
- • Local processing
- • Test text never uploaded
- • No history tracking
- • Open source code
Performance: Real-time matching <50ms, supports 10K+ chars. Compatible with ES2018+ regex features.