devtools.cihat.dev

Regex tester

Write a regular expression and see every match highlighted in your text, with its groups and position. Preview a replacement before you put it in code.

Flags

Examples

Replace
$1, $2 for numbered groups, $<name> for named groups, $& for the whole match.

How to use it

  1. Type a pattern without the surrounding slashes, and tick the flags you need.
  2. Paste the text to test. Matches are highlighted as you type, and the table lists each one with its groups.
  3. Open Replace to preview a substitution using $1 or $, then copy the pattern or the result.

Which regex flavour this uses

This page runs your browser’s own JavaScript engine (ECMAScript regular expressions). That is the flavour of JavaScript, TypeScript and Node.js, and it is close to what most editors use. Python, PHP (PCRE), Java and .NET agree on the basics but differ in details such as named-group syntax and lookbehind support.

  • Named groups: (?<year>\d{4}), reused in a replacement as $<year>.
  • Lookahead (?=…) and lookbehind (?<=…) both work.
  • The u flag makes . match a whole emoji and enables \p{L} for any letter, including Turkish ones.

Why a pattern can hang

Some patterns, such as (a+)+$ on a long line of a’s, make the engine try an exponential number of paths. The tester runs your pattern in a separate worker and stops it after 1.5 seconds, so the page never freezes; the same pattern in production could block a server.

Questions people ask

Why does it find only one match?

Without the g flag, JavaScript stops at the first match. Tick “all matches”.

How do I match a dot or a bracket literally?

Escape it with a backslash: \. matches a dot, \( a bracket, \\ a backslash.

Does \w match Turkish letters?

No. \w is only A–Z, a–z, 0–9 and _. Use [\p{L}\d_] with the u flag to include ç, ğ, ı, ö, ş and ü.

Is my text sent anywhere?

No. Matching runs in your browser.