Home › Blog › How to test a regular expression
Developer Tools guide

How to test a regular expression

Writing a regular expression is easier when you can see what it matches. Type a pattern and a test string and the matches light up.

Open the Regex Tester tool

Step by step

  1. Type a pattern. Enter the regular expression without slashes, then choose flags.
  2. Paste test text. Matches are highlighted as you type.
  3. Check groups and replace. See capture groups and preview a replacement.

Tips for better results

  • Use the g flag to find all matches, and i to ignore case.
  • Capture groups appear in the table below the test string.
  • Patterns that take too long are stopped after 2 seconds so the page stays usable.

Limits to know

  • Formats: JavaScript regular expressions
  • Size: Limited by browser memory
  • Notes: Uses the JavaScript regex engine. Other languages (PCRE, Python, .NET) have small differences. Shows up to 1,000 matches.

At a glance

ToolRegex Tester
CategoryDeveloper Tools
Works withJavaScript regular expressions
Size limitLimited by browser memory
Where it runsIn your browser tab; your input is not uploaded
CostFree, no sign-up

Frequently asked questions

Which regex flavour is used?

JavaScript (ECMAScript), the same as the RegExp object in your browser.

Why is my pattern stopped?

Some patterns, for example nested repeats like (a+)+, can take exponential time. The tester stops them after 2 seconds.

If something does not work

  • The result says a value is invalid. Check that every field has a number in the allowed range; the message names the field.
  • The numbers look different from another calculator. Rounding, rate and date conventions differ between calculators. Compare the assumptions shown with the result.
  • The page does not update. Reload it and try again; if it still fails, report it.
  • Is the answer advice? No. Results are estimates for general information.

Still stuck? Use Report a Problem and tell us the tool, your browser and what happened, or read the Help Center.

Related tools and guides

More tools like this are in Developer Tools, or browse all tools.