Regex Tester

Type a pattern and some text. The tool lists every match with its position and capture groups, marks the matches in the text and can show the text with matches replaced.

Use the tool

Loading the tool…

About Regex Tester

Test a regular expression against some text. Enter the expression and its flags, paste the text, and see the matches and their positions. You can also see the text with each match replaced.

Worked example

Enter `(\d+)-(\d+)` and paste text with numbers joined by a dash. The tool highlights each match and lists its position.

Limits

Regular expressions behave slightly differently in different programming languages. Test the final expression in the language you will use.

How to use Regex Tester

  1. Type the regular expression without slashes, and set the flags (g finds all matches).
  2. Paste the text to search.
  3. Read the match list. Tick the replace box to preview a replacement using $1, $2 and $&.

Good to know

  • This is the JavaScript flavour of regular expressions. Other languages differ in details such as named groups, lookbehind and flags.
  • Without the g flag only the first match is found. Positions count from 0.
  • A pattern that backtracks a lot on long text can make the page slow. The text is limited to 50,000 characters and the pattern to 1,000.
  • At most 1,000 matches are listed.

Frequently asked questions

What do the flags mean?

g finds all matches, i ignores case, m makes ^ and $ match at each line, s lets the dot match line breaks, and u turns on Unicode mode.

How do I use a captured group in the replacement?

Write $1 for the first group, $2 for the second, and $& for the whole match.

Is anything I type saved or sent?

No. The work happens in your browser on this page, and nothing is stored or sent to us.