Regex Tester
Test a JavaScript regular expression against sample text and see matches, positions, and capture groups — with a safety timeout against runaway patterns.
Uses your browser's native RegExp engine directly — nothing is evaluated as code, and your pattern and text are never sent to a server. Matching runs in a background worker with a 2-second safety limit, so an accidentally slow pattern can't freeze the page.
Enter a JavaScript regular expression pattern, optional flags (e.g. g, i, m), and some text to test it against. Matches, their positions, and any capture groups are listed below. Flags are honored exactly as real JavaScript would: without the g flag you'll see only the first match, matching how a non-global pattern actually behaves in code — add g to find every occurrence.
Some patterns can take an extremely long time to evaluate against certain text (known as "catastrophic backtracking"). This tool runs matching in a background worker with a 2-second limit, so a pathological pattern can't freeze the page — it will simply report that the pattern took too long.
How to use the Regex Tester
- Type your regular expression into Pattern, without the surrounding slashes.
- Set Flags (g is filled in by default); accepted flags are g, i, m, s, u, y and d.
- Paste the text to search into Test text.
- Click Test and read the Result: each match shows its start index in brackets, followed by its capture groups.
- Click Clear to reset the pattern, the text and the flags back to g.
Example: Pulling user names and domains from email addresses
Pattern (\w+)@(\w+)\.com with flags g against the text Contact [email protected] or [email protected] reports 2 matches: [8] [email protected] with Group 1: "ana" and Group 2: "example", and [27] [email protected] with Group 1: "li" and Group 2: "test".
Questions about the Regex Tester
- How do named capture groups appear?
- A group such as (?<user>\w+) is listed twice: once by number (Group 1) and once under its name (user), with the same value. A group that did not take part in the match is shown as undefined.
- What happens if my pattern or flags are invalid?
- An unknown or repeated flag gives an error such as Unknown flag: "x". or Duplicate flag: "g". before anything runs. A pattern that does not compile shows the browser's own RegExp error message, for example an unterminated group.
- Are there size limits?
- Patterns can be up to 500 characters and test text up to 20,000 characters. With the g flag, at most 500 matches are listed, and the result says when more exist.
- Will a pattern that works here behave the same in Python or PHP?
- Not always. This tool uses the JavaScript RegExp engine, so syntax and features that differ between regex flavors, such as lookbehind support or inline modifiers, may behave differently in other languages.