Regex Tester
Test and validate regular expressions
Regular Expression
//
Test Text0 matches
Replacement (Optional)
Match Results
Enter regex pattern to start matching
Common Patterns
Syntax Reference
.Any character\dDigit\wWord char\sWhitespace^Start$End*0+ times+1+ times?0 or 1{n}n times[abc]Char set()Capture groupFeatures
Professional regular expression testing tool
Real-time Highlight
Real-time highlight of matched content, visually displaying match results
Capture Group Support
Display capture group content for each match, convenient for debugging complex regex
Replace Function
Support replacement operations, can use $1, $2 to reference capture groups
Flag Toggle
One-click toggle of g/i/m/s/u flags, flexibly control matching behavior
Common Templates
Built-in common regex templates for email, phone, URL, etc.
Privacy & Security
All processing is done locally in the browser, test content is never uploaded
Frequently Asked Questions
Common questions about regular expressions
What do flags in regular expressions do?
g (global): Global matching, find all matches instead of just the first. i (case-insensitive): Ignore case. m (multiline): Multiline mode, ^ and $ match the start and end of each line. s (dotAll): Make . match any character including newlines. u (unicode): Enable Unicode mode, correctly handle Unicode characters.
What are capture groups? How to use them?
Parts enclosed in parentheses () are captured and can be referenced in replacement using $1, $2, etc. For example: regex (\d+)-(\d+) matching "2023-12" has $1 as "2023" and $2 as "12". Replacing with $2/$1 results in "12/2023".
What is the difference between greedy and non-greedy mode?
Greedy mode (default): Match as many characters as possible. For example, a.*b matches "axxbxxb" in "axxbxxb". Non-greedy mode: Add ? after quantifier to match as few as possible. For example, a.*?b matches "axxb" in "axxbxxb".
How to match special characters themselves?
Special characters that need escaping: . * + ? ^ $ { } [ ] \ | ( ). Add backslash \ before these characters to match the character itself. For example: to match "3.14" use 3\.14, to match "(test)" use \(test\)
Are there differences between JavaScript and other language regex?
This tool uses JavaScript regex engine, compatible with most languages but with subtle differences: • JavaScript doesn't support some syntax for lookbehind assertions (newer versions support) • Doesn't support some syntax for named capture groups • Flag letters may differ slightly (e.g., Python uses re.IGNORECASE). Basic syntax is universal across languages.