Regex Tester

Test JavaScript regular expressions live: see matches highlighted, capture groups, named groups and replacements. Stops runaway patterns.

Runs in your browserNo sign-upWorks offline
Ctrl+Enter to run
Input121 characters
Output
✓ ReadySample content shown

What the Regex Tester does

The Regex Tester shows what a regular expression matches as you type. Write a pattern, switch flags such as g (all matches), i (ignore case) and m (multiline) on and off, and see each match highlighted in your test text, with its position and every capture group, including named groups. Try a replacement using $1 or $<name>. Patterns that would freeze the browser, such as nested repeats, are stopped after 1.5 seconds with an explanation.

How to use it

  1. Type a pattern between the slashes.
  2. Choose flags by tapping them.
  3. Paste test text and look at the highlighted matches and the list of groups.
  4. Tick Try a replacement to preview a find-and-replace.

Example

The sample pattern for email addresses finds 3 matches in the sample text, with named groups such as user: priya.sharma and domain: example.com. Replacing with $<user> at $<domain> turns priya.sharma@example.com into “priya.sharma at example.com”.

Tips for reliable patterns

Escape characters that have special meaning when you mean them literally: a dot is \. and a plus is \+. Use ^ and $ with the m flag to match whole lines. Prefer specific classes such as [\w-]+ over .* so the pattern does not swallow more than you meant.

Nested repeats like (a+)+ or (.*)* can take exponentially long on text that almost matches, which can hang a web server. If the tester stops your pattern, rewrite it so each part can only match in one way.

Questions people ask

Is my code or data uploaded?

No. Everything runs in your browser, so config files, queries, logs and keys stay on your device. That makes it safe to use with work data.

Which regex flavour is this?

JavaScript, as used in browsers and Node.js. Most syntax is shared with Python, Java and PHP, but lookbehind and named group syntax can differ.

Why do I only get one match?

Turn on the g flag to find every match instead of the first.

Does it support Unicode letters?

Yes. Turn on the u flag and use \p{L} for any letter, including Hindi and other scripts.

Related tools