How to use Regex Tester
- Enter a JavaScript pattern without the surrounding slashes.
- Paste the sample text and choose the flags you need.
- The match report updates as you edit the pattern, flags or text. Read match positions and capture groups before using the expression elsewhere.
- Enable replacement preview to test JavaScript replacement tokens. Add optional tab-separated expected-match cases, then review each result.
Example: Regex Tester
Find three email-like strings and inspect the first match's capture groups.
Options
- Pattern
- JavaScript pattern, written without the surrounding slashes.
- Test text
- The pattern is tested against this text only, in this browser.
- Global: find every match
- With global off, the result shows the first match only.
- Ignore case
- With ignore case on, Cat and cat both match.
- Multiline: ^ and $ match each line
- Without it, ^ and $ mean the start and end of the whole text.
- Dot matches newlines
- With this on, a dot also matches the line break between two lines.
- Unicode mode
- Enables Unicode property escapes such as \p{L} and treats a surrogate pair as one code point. An emoji sequence can still contain several code points.
- Replacement preview
- Supports JavaScript substitution tokens including $&, numbered captures, named captures and $$. Replacement also runs in the time-limited worker.
- Reusable test cases
- Up to 20 lines: true or false, a tab, then sample text. Download a JSON record of the current pattern, flags, sample and cases.
- Match and group preview
- Matches are marked in the sample text. Capture values for up to the first 100 matches appear beneath it.
Supported inputs and limits
- Uses the browser's JavaScript regular-expression flavor, not PCRE or Python syntax.
- The pattern is capped at 200 characters, sample text at 100,000 characters and displayed matches at 2,000.
- A background worker is stopped after 1.5 seconds; timing depends on the visitor's device.
- Email-like matches are not email-address validation.
- Word and number example buttons fill editable fields.
More details
Replacement preview, inline highlighted matches and a complete token explainer are not provided.
Replacement text is capped at 10,000 characters, with at most 2,000 replacements and 200,000 output characters.
Patterns use the JavaScript flavor only.
Where your input is processed
This tool does not upload your inputs. See the limits for anything saved on your device.
Questions about Regex Tester
Why did a pattern work in another regex tool but fail here?
Regex flavors differ. This page uses JavaScript syntax and the selected JavaScript flags; PCRE-specific features may not compile.
Why did the pattern stop before showing matches?
Some patterns take too long on particular text. The background worker is stopped after the time limit so the page stays usable.
What does Global change?
Global asks for successive matches. With it off, the page reports the first match only.
Are match positions byte offsets?
No. Positions follow JavaScript text indexing, which counts UTF-16 code units. A character outside the basic multilingual plane may use two units.