Regex Tester: Test Regular Expressions Online
Test, debug, and validate regular expressions in real-time. Supports multiple regex flavors with syntax highlighting, match highlighting, and group capture display. Perfect for developers and data analysts.
Common flags: g (global), i (case-insensitive), m (multiline), s (dotall)
Regular Expression Flags
g - Global (find all matches)i - Case insensitivem - Multiline (^ and $ match line boundaries)s - Dotall (. matches newlines)u - Unicodey - Sticky (match at start position)How It Works
This tool uses JavaScript's RegExp engine to test your pattern against input text in real-time. As you type a regex pattern, it compiles the expression and runs it against your test string, showing all matches with their positions and captured groups.
The regex engine supports standard flags: g (global) finds all matches instead of stopping at the first one, i (case-insensitive) ignores letter case, m (multiline) makes ^ and $ match line boundaries, and s (dotall) lets dot match newline characters.
Common regex patterns included:
Match results are highlighted in the test string and displayed in a table showing the matched text, position, and any captured groups. Invalid patterns show error messages explaining what went wrong with the regex syntax.
When You'd Actually Use This
Validating form input patterns
A frontend developer builds a registration form and needs to validate email addresses, phone numbers, and passwords. They test their regex patterns against sample inputs to ensure valid data passes and invalid data gets rejected before writing the validation code.
Extracting data from log files
A DevOps engineer needs to pull IP addresses, timestamps, and error codes from server logs. They paste sample log lines and refine their regex pattern until it correctly captures all the fields they need for analysis.
Finding and replacing text in bulk
A content manager needs to reformat dates from MM/DD/YYYY to YYYY-MM-DD across hundreds of articles. They test their capture group regex to ensure it correctly identifies and rearranges the date components before running the bulk replacement.
Debugging someone else's regex
A developer inherits code with a complex regex pattern that's not working correctly. They paste the pattern and sample data into the tester to see what it actually matches, helping them understand the intent and fix the bug.
Learning regex syntax by experimentation
A junior developer studying regular expressions tests different patterns to understand how quantifiers, character classes, and anchors work. Immediate visual feedback helps them learn faster than reading documentation alone.
Scraping structured data from web pages
A data analyst needs to extract product prices, SKUs, or dates from HTML snippets. They paste the HTML and test regex patterns to isolate the specific data points before building their scraping script.
What to Know Before Using
This uses JavaScript regex flavor.JavaScript regex differs slightly from PCRE (PHP), Python, or .NET. Features like lookbehind assertions have limited support. For production code in other languages, verify patterns work in your target environment.
Special characters must be escaped.Characters like . * + ? ^ $ ( ) | \ have special meaning in regex. To match them literally, prefix with backslash. For example, match a literal dot with \. not just .
Global flag affects match behavior.Without the g flag, regex stops after the first match. With g, it finds all matches. For validation, you usually don't need g. For extraction or replacement, you typically do.
Greedy vs lazy quantifiers matter.By default, quantifiers like * and + are greedy—they match as much as possible. Add ? to make them lazy (match as little as possible). This affects what gets captured in complex patterns.
Pro tip: Start simple and build incrementally. Test each part of your regex before combining. For email validation, start with basic pattern, then add edge cases. Complex regex is harder to debug than multiple simpler patterns.
Common Questions
What does the g flag do?
The g (global) flag tells the regex engine to find all matches, not just the first one. Without g, testing "a" against "banana" finds one match. With g, it finds all three "a" characters.
How do I match exactly 10 digits?
Use \d10 to match exactly 10 digits. For phone numbers where you want exactly 10 digits with no extra characters, use ^\d10$ to anchor the pattern to start and end of string.
What's the difference between .* and .+?
.* matches zero or more of any character. .+ matches one or more. So .* matches empty strings, while .+ requires at least one character. Use .* when the content is optional, .+ when it's required.
How do I make regex case-insensitive?
Add the i flag. The pattern /hello/i matches "hello", "HELLO", "Hello", "HeLLo", etc. Without the i flag, /hello/ only matches lowercase "hello" exactly.
What are capture groups?
Capture groups are parts of the pattern enclosed in parentheses (). They extract specific portions of the match. In /(\d3)-(\d4)/, the first group captures 3 digits, the second captures 4 digits—useful for phone number parsing.
Why is my regex matching too much?
You're probably experiencing greedy matching. Quantifiers like .* match as much as possible. Try making them lazy with .*? or use more specific character classes like [^,]* to stop at commas.
Can I use regex for HTML parsing?
For simple extraction from known HTML structures, yes. For robust HTML parsing, no—HTML isn't a regular language. Use DOM parsers or libraries like Cheerio for production HTML processing. Regex works for quick extraction from predictable formats.
How do I match special characters like brackets?
Escape them with backslash. To match "[test]", use \[test\]. Characters that need escaping: . * + ? ^ $ ( ) | \ [ ]. Inside character classes [], fewer characters need escaping.
Other Free Tools
UTF-8 Validator
UTF-8 Validator: Check and Validate UTF-8 Encoding
Leet Speak Converter
Leet Speak Converter: Convert Text to 1337 Online
Free Printable Calendar Maker
Create & Print Your Custom Calendar
HTML Minifier
Free HTML Minifier & Compressor
Unix Timestamp Converter
Unix Timestamp Converter
Password Generator
Free Strong Password Generator
Barcode Generator
Free Barcode Generator