Regex Tester

Try a JavaScript regular expression against sample text. Matches, groups, and an optional replacement stay on this page, and a pattern that runs too long is stopped.

The pattern runs in a background thread and stops after 200 ms. Patterns are limited to 256 characters and test text to 50,000 characters.

Run a pattern to see matches.

How to use it

  1. Enter a pattern, flags, and the test text.
  2. Run the test. Highlights and capture groups appear when the pattern is valid.
  3. Add a replacement to preview JavaScript replace rules, including $1.

Common mistakes

  • Flags are only g, i, m, s, u, and y, once each.
  • Without g, the match list still shows later hits, but replace changes only the first hit.
  • Patterns longer than 256 characters, or text longer than 50,000 characters, are rejected.

Examples

Groups

h(el)lo with the g flag on "hello hello" finds two matches and the group el.

Date pieces

(\d{4})-(\d{2})-(\d{2})

Frequently asked questions

Processing stays in this browser tab. What you paste is not uploaded, and this tool does not write it to local storage. The pattern runs in a short-lived background thread and is stopped if it takes too long.