Regex Tester

Test and debug regular expressions online with instant match highlighting. Type a pattern, paste your text, and see every match, capture group and named group as you type. Switch to replace mode to preview replace() results, start from a library of common patterns, or use the built-in cheat sheet. This regex tester uses the JavaScript (ECMAScript) regex engine and runs entirely in your browser.

How to use the regex tester

  1. Enter your regular expression in the pattern box, without the surrounding slashes. You can also paste a full literal like /\d+/g and the pattern and flags are filled in for you.
  2. Choose flags: g finds all matches, i ignores case, m makes ^ and $ work per line, s lets . match newlines, u enables Unicode mode and y is sticky matching.
  3. Paste your test string. Matches are highlighted in alternating colours so you can see where one match ends and the next begins.
  4. Check the match details on the right: the position of every match and the value of each capture group and named group.
  5. Switch to Replace to try a replacement string. Use $1, $2 for groups, $<name> for named groups and $& for the whole match.

Features

  • Live highlighting of all matches, including zero-length matches.
  • Capture groups and named groups listed for every match.
  • Replace mode with a live preview of the result.
  • Common patterns ready to use: email, URL, IPv4, dates, Pakistani mobile numbers, international phone numbers, hex colours, strong passwords, usernames, HTML tags, duplicate words and extra whitespace.
  • Clickable cheat sheet that inserts tokens at your cursor.
  • Protection against slow patterns: matching runs in a background worker and stops after two seconds, so a pattern with catastrophic backtracking never freezes your browser.
  • Copy as a regex literal (/pattern/flags) ready to paste into your JavaScript code.
  • Private: your pattern and text stay in your browser.

Regex examples

Match an email address

[\w.+-]+@[\w-]+\.[\w.-]+ with the g and i flags matches most everyday email addresses. For signup forms, combine a simple pattern like this with a confirmation email rather than trying to cover every rule in the email standard.

Match a Pakistani mobile number

(?:\+92|0092|0)3\d{2}[-\s]?\d{7}\b matches numbers like 0300-1234567, 0333 1234567 and +923211234567.

Extract parts of a date with named groups

(?<year>\d{4})-(?<month>\d{2})-(?<day>\d{2}) captures the year, month and day by name. In replace mode, $<day>/$<month>/$<year> turns 2026-11-24 into 24/11/2026.

Remove duplicate words

\b(\w+)\s+\1\b with the gi flags finds repeated words like “the the”. Replace with $1 to keep just one.

Frequently asked questions

Which regex flavor does this tester use?

It uses your browser’s JavaScript engine, so results match exactly what RegExp, String.match() and String.replace() do in JavaScript and Node.js. Most syntax is shared with Python, PHP (PCRE) and Java, but features like possessive quantifiers, atomic groups and inline modifiers such as (?i) are not supported in JavaScript.

Why does my regex only find one match?

Without the g (global) flag, JavaScript stops after the first match. Turn on g to find all matches.

Why do ^ and $ not match each line?

By default ^ and $ match the start and end of the whole text. Turn on the m (multiline) flag to make them match at the start and end of every line.

What is catastrophic backtracking?

Some patterns, especially nested quantifiers like (a+)+, can take an extremely long time on text that almost matches, because the engine tries a huge number of combinations. This tester stops such patterns after two seconds and tells you. To fix them, make quantifiers more specific and avoid nesting + or * inside groups that are repeated.

Is my data sent anywhere?

No. Matching happens in your browser. Your pattern and test text are only saved in your own browser’s local storage so they are still there next time.

More free developer tools

See all tools