Regex Tester

//g

About this tool

This regex tester lets you build and debug JavaScript (ECMAScript) regular expressions with instant feedback. As you type a pattern, every match in your test string is highlighted, capture groups are listed, and the total match count is shown — so you can see exactly what your expression does before putting it in code. A replace box lets you preview substitutions using $1, $2 backreferences, common presets (email, URL, IPv4, dates and more) give you a starting point, and a built-in cheatsheet reminds you of the syntax. The g, i, m, s and u flags can be toggled to see how each changes the result. Everything runs in your browser using the same regex engine as Node.js and the browser itself, so what matches here matches in your application.

How to use

  1. Type your pattern in the expression box, or pick a preset to start from.
  2. Enter or paste sample text — matches are highlighted live.
  3. Toggle the flags (g, i, m, s, u) and watch the results update.
  4. Open the replace box to test a substitution with $1, $2 group references.

Common use cases

  • Writing a validation pattern for emails, phone numbers, or IDs
  • Extracting fields from log lines or free-form text
  • Testing a search-and-replace before running it across a codebase
  • Learning regex syntax with immediate visual feedback

Frequently asked questions

Which regex flavor does it use?

It uses JavaScript (ECMAScript) regular expressions, matching what runs in browsers and Node.js.

What do the flags mean?

g matches all occurrences, i ignores case, m makes ^ and $ match line boundaries, s lets the dot match newlines. Toggle them to see live results.

Can I test replacements?

Yes, enter a replacement string with $1, $2 group references to preview the replaced output instantly.

Why does my pattern match nothing without the g flag?

Without g, only the first match is found. Highlighting of all occurrences and correct match counts rely on the global flag, so turn it on to see every match.

Do these patterns work in Python or PCRE?

The core syntax is shared, but details like lookbehind support, named groups and some escapes differ between engines. This tool uses the JavaScript flavour, so adjust when porting to another language.