Javascript Regex Tester
Test a regular expression against a string with live match highlighting.
Highlights every match live as you type, using JavaScript's own RegExp engine (the exact engine your code will run with). Runs entirely in your browser; nothing you type is sent anywhere.
Need the opposite? JavaScript Validator
What is Javascript Regex Tester?
Type a pattern and a test string and see every match highlighted instantly, using JavaScript's own RegExp engine, the exact engine your code will actually run with, not an approximation. That distinction matters more than it sounds: regex flavors differ subtly between languages, and a pattern that behaves one way in, say, Python's `re` module can behave differently in JavaScript. Testing against the real `RegExp` object here means what you see is exactly what `String.prototype.match` or `.replace` would do in your actual code, computed live in your browser as you type.
How to Use the JavaScript Regex Tester
- 1
Type Your Pattern and Flags: Enter a regular expression and any flags, like g or i.
- 2
Type the Test String: Enter the text you want to test the pattern against.
- 3
Read the Highlighted Matches Instantly: Matches and capture groups are highlighted automatically as you type.
How It Works
The pattern and flags you type are compiled into a real `RegExp` object, then run against the test string with `matchAll` (when the `g` flag is set) or `match` otherwise. Each match's start and end index is used to highlight the corresponding substring in the test string, and capture groups within a match are listed separately so you can see what each `()` group captured.
Example
Pattern: \b\w+@\w+\.\w+\b with the g flag
Test string: Contact us at support@example.com or sales@example.org
Both support@example.com and sales@example.org are highlighted as matches. The pattern's `\w+@\w+\.\w+` shape matches a simplified email address, and word boundaries (`\b`) keep it from matching partway into a longer word.Common Use Cases
Building and debugging a validation pattern (email, phone number, slug format) before dropping it into form-validation code.
Testing a `.replace()` pattern against sample data to confirm it targets exactly the substrings intended, before running it against a real dataset.
Frequently Asked Questions
Common questions about Javascript Regex Tester.