Toolstia / Regex tester

Regex tester

Type a regular expression and some test text. Matches are highlighted as you type, with a table of each match, its position and its capture groups. You can also test a replacement.

Flags

This uses your browser's JavaScript regular expressions. Other languages, such as Python, PHP or Java, differ in small ways. Nothing you type is sent anywhere.

How it works

  1. Type your pattern and choose the flags you need.
  2. Paste the text to search.
  3. Read the highlighted matches and the table below.

Flags

g finds every match instead of just the first. i ignores upper and lower case. m makes ^ and $ match at each line. s lets the dot match line breaks. u turns on full Unicode handling, which you need for emoji and many non-Latin scripts.

Groups and replacement

Parts of the pattern in brackets are capture groups. The table shows each group as $1, $2 and so on. In the replacement box you can use the same $1, $2 to move text around.

A safety net

Some patterns, such as (a+)+ on a long run of a letters, can take almost forever to fail. The test runs in a background thread and stops after 1.5 seconds, so your page never freezes.

JavaScript flavour

This uses the JavaScript engine in your browser. Python, PHP, Java and others support slightly different features, such as lookbehind or named group syntax, so check the details if you will use the pattern elsewhere.

Questions

Is my text sent to a server?

No. Matching runs in your browser.

Why does my pattern show an error?

The pattern is not valid in JavaScript. The message under the box says what is wrong, such as an unclosed bracket.

How many matches does it show?

It lists up to the first 1,000 matches and shows the first 200 in the table.

What does an empty match mean?

The pattern matched at a position without taking any characters, which can happen with patterns like a*.