Regex Tester
Test a regular expression against sample text with live match highlighting.
5 matches
Match details
What is it?
This tool tests a JavaScript regular expression against a block of text, highlighting every match live as you type, entirely in your browser.
Formula Explanation
Your pattern and flags are compiled into a real JavaScript RegExp object. With the "g" (global) flag checked, every match in the text is found and highlighted; without it, only the first match is shown — matching exactly how RegExp.exec and String.match behave in real code.
Example Calculation
The pattern \d+ with the "g" flag checked highlights every run of digits in the test string — "12345", "2024", "01", "15", and "987654321" in the default example.
How to Use
- Enter a regular expression pattern (without the surrounding slashes).
- Check the flags you want: g, i, m, or s.
- Enter or edit the test string.
- Matches highlight live, with a list of each match's position and any capture groups below.
Benefits
- Highlights matches live as you type, with no need to run code to test a pattern.
- Shows capture groups for each match, not just the full match text.
- Processes everything locally in your browser — nothing is sent anywhere.
Use Cases
- Debugging a regular expression before using it in code.
- Checking whether a pattern correctly matches (or avoids) specific example inputs.
- Learning how flags like g, i, m, and s change matching behavior.
What Your Result Means
Highlighted text in the test string shows exactly what your pattern matches. The match list below shows each match's starting index and any capture groups — "undefined" for an optional group that didn't participate in that match.
Tips
- Check the g flag to see every match instead of just the first one.
- Use the i flag for case-insensitive matching, like matching "Hello" and "hello" the same way.
- Parentheses in your pattern create capture groups — check the match details list to see what each group captured.
Common Mistakes
- Forgetting the g flag and wondering why only the first match highlights.
- Including the surrounding slashes (e.g. /\d+/g) in the pattern field — only the pattern itself goes there, flags go in the checkboxes.
- Using . expecting it to match newlines — check the s flag if you need that.
FAQs
Is my text sent anywhere?
No, all matching happens locally in your browser using JavaScript's built-in RegExp — nothing is sent to a server.
What regex flavor does this use?
Standard JavaScript (ECMAScript) regular expressions, the same engine used by browsers and Node.js — syntax may differ slightly from PCRE, Python, or other regex flavors.
Why does my pattern show an 'Invalid regex' error?
JavaScript couldn't compile your pattern — check for unescaped special characters or unbalanced parentheses/brackets.
What does a capture group showing 'undefined' mean?
That group was optional (e.g. using ? or an alternation) and didn't participate in that particular match.
Pattern matching runs locally in your browser using JavaScript's RegExp and is never sent to a server.
Last updated: August 1, 2026