Create, Test & Debug Regular Expressions
A powerful tool for building, testing, and debugging regular expressions with real-time matching, syntax highlighting, and multi-language code generation.
The Regex Tester provides a comprehensive interface for building and testing regular expressions. Whether you are validating user input, parsing data, or searching text patterns, this tool has you covered.
Auto-Testing
The tool automatically tests your regex as you type with a 300ms debounce. You can also manually trigger testing with the Test button.
The pattern input section is where you enter your regular expression for testing.
Enter your regex pattern in the input field. The pattern is displayed in the classic regex format.
The tool analyzes pattern complexity and displays:
Patterns are shown in the standard regex format: /pattern/flags
Flags modify how the regular expression behaves. Toggle them on or off to change matching behavior.
Find all matches rather than stopping after the first match.
Default: EnabledMake the pattern case-insensitive. Matches both uppercase and lowercase characters.
/hello/i matches "HELLO"Make ^ and $ match the start and end of each line, not just the whole string.
Treat the pattern as a sequence of Unicode code points. Enables proper handling of emojis and international characters.
Make the dot (.) match newline characters as well. By default, dot does not match newlines.
Perform a sticky search that matches only at the position indicated by the lastIndex property.
The test string section is where you enter the text to test against your regex pattern.
Paste or type your test string in the textarea:
Quick-fill buttons for common test cases:
The results area has three tabs that show different views of your regex matches.
Shows all matches found in your test string:
Visual highlighting of matches in the test string:
Generated code snippets for multiple languages:
Error Handling
Invalid regex patterns will show an error alert with details about the syntax issue. Common errors include unescaped special characters, unbalanced parentheses, or invalid quantifiers.
The pattern library provides a collection of pre-built regex patterns for common use cases. Click any pattern to apply it instantly.
^[\w\.-]+@[\w\.-]+\.[a-zA-Z]{2,}$Matches valid email addresses with standard format.
https?:\/\/(www\.)?[-a-zA-Z0-9@:%._\+~#=]{1,256}\.[a-zA-Z0-9()]{1,6}\b([-a-zA-Z0-9()@:%_\+.~#?&//=]*)Matches HTTP and HTTPS URLs.
^(\+?1-?)?\(?([0-9]{3})\)?[-. ]?([0-9]{3})[-. ]?([0-9]{4})$Matches US phone number formats.
^(?:(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.){3}(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)$Validates IPv4 addresses.
^#([A-Fa-f0-9]{6}|[A-Fa-f0-9]{3})$Matches hex color codes (#FFFFFF or #FFF).
^(0[1-9]|1[0-2])\/(0[1-9]|[12][0-9]|3[01])\/(19|20)\d\d$Validates US date format.
^(?=.*[a-z])(?=.*[A-Z])(?=.*\d)(?=.*[@$!%*?&])[A-Za-z\d@$!%*?&]{8,}$Strong password: 8+ chars, upper, lower, number, special.
^[a-zA-Z0-9_-]{3,16}$Alphanumeric usernames, 3-16 characters.
LT_slash_Q_WS_eq_DOT_quotes_DASH_colon_RTMatches HTML tags with attributes.
The Code tab generates ready-to-use code snippets for your regex in multiple programming languages.
Standard JavaScript RegExp usage:
const pattern = /pattern/flags;Python re module with flag support:
re.search(pattern, text, flags)Java Pattern and Matcher classes:
Pattern.compile(pattern, flags)Rust regex crate usage:
Regex::new(pattern)Ruby regex literals:
text =~ /pattern/flagsC# Regex class with options:
new Regex(pattern, flags)One-Click Copy
Each code snippet has a copy button for quick clipboard access. The generated code includes your pattern and selected flags.
Your regex is tested automatically as you type with debounced updates for performance.
See matches highlighted directly in the test string for immediate visual feedback.
View match positions, lengths, and captured groups for each match.
Pre-built patterns for common use cases like email, URL, phone, and more.
Generate ready-to-use code in JavaScript, Python, Java, Rust, Ruby, and C#.
See execution time and complexity analysis for your patterns.
Instant feedback on invalid regex patterns with helpful error messages.
Save frequently used patterns to your favorites for quick access.
Quick-fill test strings for common patterns to speed up testing.
Build and test regex patterns for validating user input like emails, phone numbers, and addresses.
Extract specific data from text like dates, prices, or custom formats using capture groups.
Create complex search patterns for find-and-replace operations in code or text editors.
Parse log files and extract relevant information using custom regex patterns.
Build patterns to identify code elements like function definitions, comments, or specific syntax.
Interactive tool for learning and experimenting with regular expression syntax.
A quick reference guide for common regex syntax and special characters.
[abc]Any of a, b, or c[^abc]Not a, b, or c[a-z]Character between a-z.Any character\wWord character\dDigit\sWhitespace^Start of string$End of string\bWord boundary\BNot a word boundary*0 or more+1 or more?0 or 1{3}Exactly 3{3,}3 or more{3,5}3 to 5(...)Capture group(?:...)Non-capturing group(?=...)Positive lookahead(?!...)Negative lookahead\1, \2Backreferences