Regex Tester

Test and debug regular expressions

Regex Tester

Test and debug regular expressions

Highlighted Matches:

Matches will be highlighted here...

Match Details:

Match information will appear here...

Replace Matches:

Hint: use $1 through $9 for capture groups and $& for the whole match. The global (g) flag is applied automatically so every match is replaced.

Total Matches: 0

Quick Reference

Character Classes:
. - Any character
\d - Digit [0-9]
\w - Word [a-zA-Z0-9_]
\s - Whitespace
Quantifiers:
* - 0 or more
+ - 1 or more
? - 0 or 1
{n,m} - Between n and m
Anchors & Groups:
^ - Start of string
$ - End of string
() - Capture group
(?:) - Non-capture group

Features

  • Real-time regex testing
  • Visual match highlighting
  • Support for all regex flags
  • Common pattern examples

How to Use

  1. 1. Enter your regex pattern and select flags
  2. 2. Type or paste your test string
  3. 3. See matches highlighted in real-time
  4. 4. Review match details and export results

Regex Tester FAQs

How does Replace All work?

Enter a replacement string in the Replace Matches box and click Replace All. The tool compiles your pattern with the chosen flags, adds the global flag automatically so every match is replaced, and shows the finished output together with the total replacement count and a Copy Output button.

Can I reference capture groups in my replacement text?

Yes. Use $1 through $9 to insert the numbered capture groups from your pattern, and $& to insert the entire matched text. Wrapping a group in new text is just a matter of typing the surrounding characters around $1 in the replacement field.

Which regex flags can I toggle?

Four checkboxes control the flags: g for finding all matches, i for case insensitive matching, m to make the start and end anchors work per line, and s to let the dot match newlines. Invalid patterns show an inline error, while valid ones highlight matches in real time and list every match value, position, and group in the details panel.

Is there a way to try the tester without writing a pattern?

The Email, URL, and Phone buttons above the pattern field load a ready-made regular expression along with a matching sample test string, so highlighting, match details, and replace behavior can be explored immediately. You can also copy the current pattern with its flags or export the session results as a JSON file.

Are my patterns or test strings stored anywhere?

No. Matching and replacing run on the RegExp engine built into your browser, so the text never leaves the page. The export option only writes a local JSON file when you click it yourself.