Regex Tester
Test JavaScript regular expressions instantly with browser-side execution, optional flags, match listings, and captured group inspection. Perfect for debugging patterns, validating search rules, and teaching regex behavior safely.
Supported JavaScript flags like g, i, m, s, u, and y.
Continue Your Code Journey
What is Regex Tester?
The Regex Tester lets you write a regular expression and test it against sample text in real time. It highlights all matches in the input text, shows match details including capture groups, and lets you toggle flags (g, i, m, s) to change matching behavior. The tool helps you debug regex patterns by showing exactly what matches and what does not. All processing happens in the browser.
How does Regex Tester work?
This tool constructs a JavaScript RegExp from your pattern and flags, runs it against the test string using matchAll, and displays every match with its index, full match text, and captured groups. Invalid regex patterns trigger a descriptive error message.
Key Features
- Real-time regex matching with highlight
- Shows match count and positions
- Displays capture groups per match
- Toggle flags: global, case-insensitive, multiline, dotAll
- Error messages for invalid patterns
- Copy matches to clipboard
- Quick preset patterns
- Runs in the browser with no uploads
Common Use Cases
Debugging a regex pattern
Write a regex and test it against sample strings to verify it matches the intended text.
Extracting capture groups
Test a regex with parentheses to see what each group captures for use in code.
Learning regular expressions
Experiment with regex syntax and see immediate feedback on what matches.
Validating input patterns
Test a regex for validating emails, phone numbers, or URLs against real examples.
How to Use This Tool
Enter your regex
Type the pattern in the regex input field (without delimiters).
Enter test text
Paste the text you want to match against.
Set flags
Toggle global (g), case-insensitive (i), multiline (m), or dotAll (s) flags.
Review matches
See highlighted matches, match count, and capture groups.
Pro Tips
- 1
Use the global flag (g) to find all matches, not just the first one.
- 2
Capture groups are numbered from left to right starting at 1.
- 3
Test with edge cases like empty strings and special characters.
- 4
The preset patterns provide starting points for common use cases.
Frequently Asked Questions
How do I enter a regex pattern?
Type the pattern without delimiters. For example, enter \d+ to match digits, not /\d+/. The flags are toggled separately.
What do the flags mean?
g (global) finds all matches. i (case-insensitive) ignores case. m (multiline) makes ^ and $ match line boundaries. s (dotAll) makes . match newlines.
What are capture groups?
Capture groups are parts of the pattern wrapped in parentheses. Each group captures the matched text so you can extract specific portions.
Is my input sent to a server?
No. All regex execution happens in your browser using JavaScript. Nothing is transmitted.
What if my regex is invalid?
The tool shows a descriptive error message from the JavaScript regex engine explaining what is wrong with the pattern.