Regex Tester Calculator

Enter a regular expression and sample text to see the matches.

How it is calculated

The pattern is wrapped in slashes and run by a PCRE (Perl-compatible) regular-expression engine, so PCRE syntax applies, which differs from JavaScript or POSIX in places such as lookbehind and named groups. A bare slash in your pattern is escaped for you, and one you have already escaped (\/) is left alone, so both a/b and a\/b work. Only the flags i (ignore case), m (^ and $ match at each line), s (dot matches newline), x (extended, ignores whitespace) and u (UTF-8) are kept; any other letter, including g, is dropped.

The tool reports a status (match, no match or invalid pattern), the number of matches and a numbered list of the matched text. All matches are always found, so no global flag is needed. Only the whole match is listed, not the contents of capture groups, and at most 50 matches are shown, followed by an ellipsis. Pattern and text must both be filled in, otherwise there is no result.

Worked example

Find e-mail addresses in the sample text with the pattern \b[\w.+-]+@[\w-]+\.[\w.]+\b and the flag i. The scan goes left to right through Write to ann@example.com or bob.smith@mail.example.org, not to @home or info@. It finds ann@example.com first, then bob.smith@mail.example.org. The fragments @home and info@. have no characters on one side or no domain with a dot, so they fail. The status is Match, the count is 2, and the list shows the two addresses numbered 1 and 2.

Try this example →

Common mistakes

  • Typing the pattern with delimiters and flags the way JavaScript shows it, such as /abc/gi. The slashes become part of the pattern, so /abc/ does not match the text abc; the flags go in their own field.
  • Expecting the list to show what each group captured. Only the full match is listed: (a)(b) on ab lists just ab. Test groups by turning them into separate patterns.
  • Forgetting the m flag when using ^ or $ on multi-line text: without it, ^\w+ finds only the first word of the entire text, with it the first word on each line.
  • Writing a pattern that can match an empty string, such as x*. On the text abc it reports 4 matches, all empty, which is easy to misread as real hits.
  • Expecting case-insensitive matching without the i flag, or relying on g to find all matches. Matching is case-sensitive unless i is set, while all matches are found regardless.

About this calculator

This tool runs a regular expression against sample text using standard regex syntax — character classes, quantifiers (*, +, ?, {n,m}), anchors (^, $), and groups — and lists every match it finds along with a total count, letting you verify a pattern before dropping it into code. Regex engines vary slightly in their exact behavior (PCRE, JavaScript's RegExp, POSIX), so testing a pattern interactively catches edge cases like greedy versus lazy quantifiers or unescaped special characters before they cause a bug in production.

Developers validating form input, writing a log-parsing script, or building a URL router use a regex tester constantly, since regex syntax is notoriously easy to get subtly wrong — a pattern that matches your first three test cases can silently fail on the fourth. It's also a common teaching aid for learning regex, letting a student see exactly which parts of the text a pattern matches rather than reasoning about it purely on paper (this tool lists the whole matches, not the contents of individual capture groups).

Was this helpful?

You can pick up to 3 reactions.

Comments

  • Be the first to comment.

Popular calculators

All Calculators