Regex Tester
Test JavaScript regular expressions against sample text, with match and capture-group details.
Input & settings
What this tool does
Regex Tester compiles a JavaScript regular expression and lists up to 250 matches, including numbered groups and named groups. Global search is used even when you omit g, so every non-overlapping match can be collected. An empty match advances the search by one character. Flags may be d, g, i, m, s, u, or y, without duplicates.
How to use it
- Enter the pattern, flags, and sample text.
- Choose Find matches.
- Copy the JSON result when you need it. Reset clears the fields.
Practical example
The pattern \b\w+@\w+\.\w+\b with flags gi finds the two addresses in the sample sentence.
Tips
The pattern is limited to 300 characters and the text to 50,000. The sample search and every later search run in a worker and stop after about 1.5 seconds. That keeps this tab responsive. It does not prove that a pattern is safe or fast in every JavaScript engine.
Questions
Why does a search without g still find more than one match?
The tester adds g when it is missing so it can list successive matches. A sticky or lastIndex-sensitive pattern can behave differently from a single exec call.
What happens with an invalid pattern?
The page reports the JavaScript syntax error and clears the match list.
How are empty matches handled?
A zero-length match is recorded and the search moves one character forward so it cannot loop forever on that spot.
Can a pattern freeze the browser?
The worker time limit is meant to stop a runaway search in this tool. It is not a general ReDoS defense, and a pattern can still be expensive.
Are the results sent away?
No. The worker is created in this page and receives only the pattern, flags, and text you entered.