Yuzool

Dev Tools

Regex tester

Type a pattern and some text: every match lights up as you type, with its groups, and each part of the pattern is explained in plain English. It uses your browser’s own JavaScript regex engine.

A pattern, explained

This is how the page reads the pattern ^\d{3}-[A-Z]+$, part by part:

PartMeans
^the start of the text
\da digit (0-9)
{3}…exactly 3 times, as many as possible
-the character "-"
[A-Z]one character from: A to Z
+…one or more times, as many as possible
$the end of the text

The flags

Flags change how the whole pattern works. Turn them on and off with the letters after the pattern:

FlagDoes
gglobal: find every match, not just the first
iignore case
mmultiline: ^ and $ match at each line
sdotAll: . matches line breaks too
uUnicode: read the pattern as Unicode code points
ysticky: match only at lastIndex

Replacing

In the Replace box, $1, $2 … put back what each group matched, $<name> a named group, and $& the whole match. So with the pattern (\w+)@(\w+) and the replacement $2: $1, "ann@example" becomes "example: ann".

How to use it

  1. Type your pattern between the slashes and pick the flags.
  2. Paste the text to test it against: matches are highlighted and listed with their groups.
  3. Type a replacement to see the text after replacing, and read What the pattern means to check it does what you think.

Questions

Which regex flavour is this?

JavaScript’s (ECMAScript), run by your browser. Most of it is the same in Python, Java, PHP (PCRE) and .NET, but look-behind support, named groups and \p{…} differ in a few places.

Why does my pattern match nothing?

Common causes: a character that needs a backslash, such as . ? + ( or ), anchors ^ and $ without the m flag on multi-line text, or case (turn on i).

What is a capture group?

Brackets ( ) around part of a pattern save what that part matched, so you can read it out or reuse it as $1 in a replacement. (?: ) groups without saving.

Is my text sent anywhere?

No. The pattern runs in your browser on your device.

Related tools

Open all 35 Dev Tools. Everything runs in your browser; nothing you paste is uploaded.

Settings

History

Snippet