Regex Tester

Regular expressions are notoriously easy to get subtly wrong — this runs a pattern against real test text immediately, showing every match rather than making you guess whether the pattern actually does what you intended.

Inputs

Result

2 match(es)

66, 3

How the regex tester works

The pattern and flags are compiled into a live regular expression and matched against the provided test text.

With the global ('g') flag, every non-overlapping match in the text is returned; without it, only the first match is found.

Worked example: pattern \d+ against 'Order 66 shipped in 3 days'

  1. \d+ matches one or more consecutive digits.
  2. With the 'g' flag: 2 matches found — '66' and '3'.
  3. Without the 'g' flag, only the first match, '66', would be returned.

Common mistakes to avoid

Forgetting to escape special regex characters that appear literally in the target text

Characters like '.', '*', '+', '(' and ')' have special meaning in regex syntax — to match them as literal characters in the text, they need to be escaped with a backslash (e.g. \. to match an actual period), or the pattern will behave unexpectedly.

Omitting the global flag when expecting all matches, not just the first

Without the 'g' flag, JavaScript's regex matching stops at the first match found — a very common source of 'why is it only finding one result' confusion when testing a pattern intended to catch every occurrence.

Frequently asked questions

What does \d+ actually mean in plain terms?

\d matches any single digit (0-9), and the + means 'one or more of the preceding thing' — combined, \d+ matches any run of consecutive digits, however long.

What's the difference between the 'g' and 'i' flags?

'g' (global) finds all matches instead of stopping at the first; 'i' (case-insensitive) makes letter matching ignore uppercase/lowercase differences. Both can be combined, like 'gi'.

Why does my pattern work in one context but not another?

Regex syntax has minor variations between programming languages and tools — a pattern tested here (using JavaScript's regex engine) should transfer well to most languages, but some advanced features differ subtly between implementations.

How do I match an exact literal string rather than a pattern?

If the text you want to match contains no special regex characters, it works as a literal pattern directly — for text that does contain special characters, escape each one with a backslash first.

Related calculators