Skip to content

All tools

Regex Tester

Test regular expressions with live highlighting and replace.

  • 100% free
  • JavaScript flavour
  • Runs in your browser
//gu
0 characters

Matches

Enter a pattern and some text to see matches highlighted.

Last reviewed by the OnlineToolPro team

What is the Regex Tester?

Write a regular expression and see every match highlighted as you type, with capture groups listed. Try a replacement to see the result. Uses the JavaScript regex engine built into your browser.

How it works

How to use the Regex Tester

3 simple steps. No experience needed.

What can you use it for?

  • Build and debug a pattern before putting it in code.
  • Find all email addresses or dates in some text.
  • Preview a find-and-replace across a document.

The flags

g finds every match instead of only the first, i ignores letter case, m makes ^ and $ match at the start and end of each line, s lets . match line breaks, and u enables full Unicode support.

Testing replacements

In the replacement field, $1, $2 and so on insert capture groups, and $& inserts the whole match. For example, replacing (\w+)@(\w+) with $2 at $1 swaps the parts around the @.

FAQ

Frequently asked questions

Which regex flavour is this?

JavaScript (ECMAScript). Most patterns work the same in other languages, but some features differ.

Will my regex work in Python or PHP?

Most everyday patterns work the same. Differences appear with lookbehinds, named groups syntax and some flags, so test in your target language too.

Why does my pattern match an empty string?

Patterns like a* can match zero characters. Use + instead of * if at least one character is required.

Other tools you might find useful next.

More Developer Tools

Format, convert and check code and data. 9 free tools.

Browse Developer tools
Other categories:YouTubeTextImagesPDFs