Back to home

Regex Tester

Type a pattern and some text and see every match highlighted at once, with its groups. Try a replacement and read what each part of the pattern means.

  1. Type your regular expression and pick flags
  2. Paste the text to test
  3. Check matches, groups and the replacement
Loading the tool...

Your files never leave your device

Testing a regular expression

A regular expression describes a pattern of text, such as a date, an email or a code. Type the pattern, switch on the flags you need and paste some test text. Every match is highlighted at once, with its groups listed, and a plain-language list explains what each part of the pattern means.

A worked example

Use the pattern (\d\d\d\d)-(\d\d)-(\d\d) with the g flag on the text 2024-05-17 and 2025-01-02. Two matches are found, and the groups of the first are 2024, 05 and 17. In the Replace with box write $3/$2/$1 and the text becomes 17/05/2024 and 02/01/2025.

The explanation panel reads the pattern from left to right. It says that \d is a digit, that each pair of parentheses is a capturing group and that the dash is matched as a plain character, which makes it a good way to learn.

Common mistakes

Special characters need a backslash when you mean them literally. To match a dot write \. and to match an opening bracket write \[. Without the g flag only the first match is found, which surprises many people.

Nested repeats such as (a+)+ can take exponential time on some text. If the page warns that a pattern is slow, simplify it. The tool uses the JavaScript engine, so features from other languages, such as possessive quantifiers, may not be available.

Frequently asked questions

Is my text uploaded?

No. Matching runs with your browser's own regex engine on your device.

Which regex flavour is used?

JavaScript (ECMAScript). Some features from other languages, such as possessive quantifiers, are not available.

Why does the page say a pattern is slow?

Some patterns take exponential time on certain text. Simplify nested repeats such as (a+)+ to avoid freezing the page.

How do I match a literal dot or bracket?

Escape it with a backslash, for example \. or \[. Inside a character set many symbols are already literal.

How do named groups work?

Write (?<year>\d\d\d\d) and the match list shows the group by name. In a replacement use $<year>.

Does the explanation cover everything?

It explains common tokens. Complex or rare syntax may show as plain text.

Related tools

Save this tool to use it later

Add this page to your browser bookmarks by pressing Ctrl + D