Regex Tester

Test a regular expression against sample text with live highlighting, capture groups, named groups and a replace preview.

Loading tool…

Your pattern and test text stay in your browser. Nothing is transmitted.

What the Regex Tester does

The regex tester on this page will test a regular expression against sample text with live highlighting, capture groups, named groups and a replace preview. Everything runs inside this page, so the work happens on your own device rather than on a server. It is most often used for developing and debugging a pattern before putting it in code. We run a second free tools site as well — FreeToolsWorld.org.

How to use it

  1. Type your regular expression in the pattern field.
  2. Toggle the flags you need — g for all matches, i for case-insensitive, m for multiline.
  3. Paste test text and watch matches highlight as you type.
  4. Use the replace field to preview a substitution.

How it works

The tester uses the browser's own RegExp engine, so behaviour matches JavaScript exactly. That is worth knowing if you are writing patterns for another language: JavaScript lacks lookbehind in older browsers, handles Unicode differently without the u flag, and uses different syntax for some constructs than PCRE, Python or Go.

Matches are listed with their index and every capture group, including named groups written as (?<name>…). Named groups make a complex pattern far more maintainable than counting parentheses to find group 4.

A guard stops patterns that match an empty string from looping forever with the global flag, which would otherwise freeze the tab. Catastrophic backtracking — a pattern like (a+)+b against a long string of a characters — can still be slow, and is worth understanding since it is a real denial-of-service vector in server-side code.

When to use it

  • Developing and debugging a pattern before putting it in code.
  • Checking what a regex from a tutorial actually matches.
  • Previewing a find-and-replace with capture group references.

Common mistakes to avoid

  • Writing a pattern that works in JavaScript and assuming it works in Python or PCRE, where syntax differs.
  • Forgetting the g flag and wondering why only the first match is found.
  • Using a regex to parse HTML, which nested structures make unreliable.

Frequently asked questions

Does this match other languages' regex?

It uses the JavaScript engine. Core syntax is shared across languages, but lookbehind support, Unicode property escapes and named group syntax all vary. Test in your target language before relying on an edge case.

Why is my pattern slow?

Probably catastrophic backtracking — nested quantifiers such as (a+)+ cause exponential work on non-matching input. Restructure the pattern to avoid ambiguity about where one quantifier ends.

Related tools

See all developer tools →