Regex Tester
Test regular expressions with live highlighting, match table, and replace mode
About this tool
The ToolNinja Regex Tester is a free online regular expression tester with live match highlighting. Test any regex pattern against a string and see all matches highlighted in real time as you type โ no button press needed. Whether you need to quickly regex test a pattern, debug a complex regular expression, or use it as a regex web tool for JavaScript development โ the results appear instantly. The match table shows every match with its exact index, length, and capture groups so you can verify your pattern precisely. Use it to test email validation regex, URL matching patterns, phone number formats, date patterns, and anything else your project requires. Replace mode lets you preview regex substitutions before using them in code. Supports all JavaScript regex flags: global (g), case-insensitive (i), multiline (m), and dotAll (s). A fast, privacy-first regex101 alternative. Runs 100% in your browser โ your test strings and patterns never leave your machine. No login, no account required.
When to use it
- โTesting email validation, URL matching and phone number regex patterns
- โDebugging complex regular expressions with live match highlighting
- โVerifying regex capture groups before using them in JavaScript code
- โTesting regex replace patterns to preview substitution results
- โLearning regex syntax interactively with real-time feedback
- โValidating regex patterns for form input validation and data parsing
Tips
- โThe g flag finds all matches โ without it, only the first match is returned.
- โThe i flag makes the pattern case-insensitive.
- โNamed capture groups (?<name>pattern) make extraction code far more readable than numbered groups.
- โUse ^ and $ anchors to match the full string โ without them the pattern can match anywhere.
Frequently asked questions
Why does my regex work in Python but not here?
This tester uses JavaScript regex syntax. Python, PCRE, and .NET regex engines have slightly different syntax for features like lookaheads, named groups, and character class shorthands. For example, Python uses (?P<name>) for named groups while JavaScript uses (?<name>).
What's the difference between .* and .*? (greedy vs lazy)?
.* is greedy โ it matches as many characters as possible. .*? is lazy โ it matches as few characters as possible. Greedy matching is the default and often causes unexpected over-matching, especially in HTML parsing.
How do I match a literal dot, bracket, or other special character?
Escape it with a backslash: \. matches a literal period, \( matches a literal parenthesis. The characters that need escaping in regex are: . * + ? ^ $ { } [ ] | ( ) \
Why does my regex cause the page to freeze?
Catastrophic backtracking โ a regex engine can get stuck in exponential time on certain pattern and input combinations. Patterns like (a+)+ on a string like 'aaaaaab' are classic examples. Simplify nested quantifiers to fix it.