💻 Developer Tools

Regex Tester

Enter a pattern and flags, and the matches in your test string light up as you type. Check the match count, capture groups, and a replacement preview. Everything stays in your browser.

Examples (click to load a pattern and sample text)

Paste a slash-style regex like /\d+/gi into the pattern box and the flags are picked up automatically.

Flags
(Enter a pattern and a test string to see matches here)

How to Use the Regex Tester

New to regex? Start by clicking an example button (Email address, URL, Date and so on). The pattern and a matching sample text load instantly, so you can see exactly where it lands. Once you are comfortable, type your own pattern into the Regular Expression field, tick the flags you need (g / i / m / s), and paste the text you want to test into the Test String box. Matches are highlighted as you type, and the match count and capture groups are listed below.

Copy a slash-style regex such as /\d{4}-\d{2}-\d{2}/g from your code and paste it into the pattern box — the flags are read automatically. Handy for a quick check before you use it in an editor or program.

  • Highlight: The parts of your test string that match the pattern are shown in color, so you can see at a glance where it lands.
  • Matches: Shows how many matches were found, plus each match's full text and capture groups ($1, $2…).
  • Replace Preview: Enter a string in the Replacement field to preview the result of str.replace(). Back-references such as $1 work exactly as they do in standard JavaScript.
  • Flags: Toggle g (all matches), i (ignore case), m (multiline), and s (let . match newlines).

Handy For

  • Checking patterns that extract dates, IPs or email addresses from logs and text
  • Trial runs before you wire a pattern into form validation
  • Confirming a replacement (with $1 references) before using it in an editor or on the command line
  • Verifying that capture groups pull out exactly the parts you intended

Frequently Asked Questions

Is my pattern or text sent to a server?
No. Matching and replacement are performed entirely in your browser. The pattern and text you enter are never transmitted to or stored on any server, so you can test text that contains sensitive data with confidence.
What do the g / i / m / s flags do?
g finds every match in the text (global), i ignores case, m makes ^ and $ match the start and end of each line (multiline), and s lets . match newline characters too (dotAll). Toggling a checkbox updates the result on the spot.
How do capture groups and the replace preview work?
Parts of the pattern wrapped in parentheses ( ) become capture groups and are listed per match as $1, $2 and so on. Enter a string in the Replacement field to preview the result of str.replace(), where back-references like $1 work as in standard JavaScript. The g flag controls whether one or all matches are replaced.