Regex Tester

A regular expression that looks right can still match the wrong things: the email pattern that also accepts ‘a@b’, the date pattern that misses half your formats, the greedy quantifier that swallows a whole paragraph. The only reliable way to trust a pattern is to test it against realistic text before it ships. This tester gives you instant feedback as you type: matches light up in your sample text, a results panel lists every match with its capture groups, and invalid patterns report the error immediately instead of failing silently in production code.

Quick Answer: Type your regular expression in the pattern box, paste sample text below, and matches are highlighted live. The results list shows every match with its position and capture groups, and errors are reported as you type.

Free Online Tool

Regex Tester

Type a pattern and watch matches light up in your sample text, with groups listed below.







0Matches

How to Use the Regex Tester

  1. Type your regular expression into the Pattern field, without the surrounding slashes used in code.
  2. Tick the flags you need: g for all matches, i for case-insensitive, m for multiline anchors, s for dot-matches-newline.
  3. Paste realistic sample text into the test area, including tricky cases you expect to match and to reject.
  4. Read the highlighted text and the match list to confirm the pattern behaves as intended.
  5. Refine the pattern and re-check both the matches and the near-misses before copying it into your code.

Key Features

  • Live highlighting of every match directly inside your sample text as you edit the pattern.
  • Match inspector listing each match, its character position and all of its capture groups.
  • Standard JavaScript flags: global, case-insensitive, multiline, dotAll, plus unicode and sticky if you add them in code.
  • Instant syntax error reporting with the engine’s own message, so broken patterns are obvious.
  • Everything runs client-side; proprietary log samples and data extracts stay in your browser.

Best Practices and Tips

  • Build test text that includes deliberate failures: strings that should almost match are where pattern bugs hide.
  • Anchor patterns with ^ and $ when validating whole fields, or you will accept any string that merely contains a match.
  • Watch greedy quantifiers: a .* between quotes will run to the last quote on the line, not the first.
  • Use named groups in production code for readability, but test the structure here first with numbered groups.

Common Mistakes to Avoid

  • Forgetting the global flag and concluding a pattern only matches once in real data.
  • Testing against one perfect example instead of the messy real-world text the pattern will actually meet.
  • Escaping characters in the tester that your programming language’s string syntax will un-escape again, changing the pattern.
  • Writing a pattern that suffers catastrophic backtracking on long non-matching input; test with a long near-miss string.

Frequently Asked Questions

Which regex flavour does this tester use?

It uses the JavaScript regular expression engine built into your browser, which shares its core syntax with most modern languages. A few features differ between flavours, notably lookbehind support and named-group syntax, so check your target language’s documentation for edge cases.

Why does my pattern stop after the first match?

Without the global flag, matching stops at the first success. Tick the g flag to find every match in the text. In code, the same applies: use the global flag or a match-all method.

How do I match a literal dot or slash?

Escape it with a backslash: \. matches a full stop instead of any character. Inside a character class most punctuation needs no escaping, which is why [.] is a common way to write a literal dot.

What are capture groups?

Parentheses in a pattern capture the part of the text they matched, so you can extract pieces, like the year and month out of a date. The results panel shows group 1, 2 and so on for each match so you can verify the pieces are the ones you expect.

Is my sample text uploaded?

No. The pattern is compiled and run by your browser’s own engine. You can safely test against log lines, customer data samples or unreleased content.

Related Tools