Regex Tester

Test a regular expression against sample text and inspect the matches.

Pattern

Matches

No regex executed yet.

How to Use This Regex Tester

Enter a pattern (without the surrounding slashes), any flags you want (i for case-insensitive, m for multiline, and so on), and the text to test against. Click Run Regex to see every match, listed with its matched text and the character index where it starts in the test text.

How Matching Works Here

The global flag is always applied automatically, even if you don't include it, so this tool always shows every match in the text rather than stopping at the first one. If your pattern is invalid JavaScript regex syntax, the output shows the exact error message instead of results, which usually points to what needs fixing.

Watch Out for Catastrophic Backtracking

Some patterns are technically valid but computationally dangerous. Nested quantifiers — a repeated group inside another repeated group, like (a+)+ — can force the regex engine to try an exponential number of ways to match a failing input before giving up. A pattern like (a+)+$ tested against thirty a's followed by a single character that breaks the match can take noticeably longer to fail with each additional character added to the test string, sometimes long enough to freeze the tab. If a pattern that looks simple runs unexpectedly slowly, look for nested repetition first.

FAQ

Do I need to add the global flag myself?

No, it's applied automatically so every match is returned, not just the first one.

What regex syntax does this support?

Standard JavaScript regular expression syntax, since the pattern runs through the browser's own RegExp engine.

Why does it say "No matches found" even though I'm sure the pattern is right?

Double-check your flags — a pattern that should be case-insensitive needs the i flag, for example, or check for typos in the pattern itself.

Why did my browser freeze or hang when I ran a pattern?

You likely hit catastrophic backtracking — patterns with nested quantifiers, like (a+)+, can force the regex engine to try an exponential number of ways to match certain inputs. A pattern like (a+)+$ tested against a long run of a characters followed by one non-matching character can take seconds or longer to fail, even though the pattern looks harmless. Restructuring nested repeated groups usually fixes it.