Regex Tester
Enter a JavaScript regular expression, choose flags and paste test text. Matches are highlighted, counted and listed with their capture groups.
Common flags: g (all matches), i (ignore case), m (multiline), s (dot matches newline), u (Unicode).
| # | Index | Match | Groups |
|---|
Your input stays in your browser and is not sent to a server by this page.
What it is and when to use it
A regular expression is a compact pattern for finding, validating or extracting text. This tester uses the JavaScript regular expression engine of your browser, so the results match what RegExp, String.match and String.replace do in your own code.
How to use
- Type a pattern without the surrounding slashes.
- Set flags, for example gi.
- Paste your test text; results update as you type.
- Read the highlighted matches and the group table below.
Example
Pattern: [\w.+-]+@[\w-]+\.[\w.]+ Flags: gi
Matches: hello@example.com, support@ilovedev.org
Tips and common mistakes
- Escape special characters such as
. * + ? ^ $ { } ( ) | [ ] \with a backslash when you want to match them literally. - Quantifiers are greedy by default.
.*takes as much as possible, while.*?stops at the first match. - Without the
mflag,^and$match only the start and end of the whole text, not each line. - JavaScript syntax differs from PCRE, Python and PHP. Inline flags such as
(?i)and possessive quantifiers are not supported. - Nested quantifiers like
(a+)+can cause catastrophic backtracking on long input. Keep patterns simple and test with large samples.
Frequently asked questions
Which regex flavor does it use?
The JavaScript engine of your own browser, so results match what JavaScript code in that browser would produce.
What happens with slow patterns?
Tests run in a background worker and are stopped after 2 seconds. This limits the harm from catastrophic backtracking, but it cannot predict every slow pattern in advance.
Are there limits?
Test text is limited to 200,000 characters and the first 1,000 matches are shown.