← Home Blog
Development

Regex Tester Guide: Test and Debug Regular Expressions

Updated: August 2026 • 7 min read
Regex Tester Guide

A regular expression, or regex, is a compact pattern for matching text. A regex tester lets you type a pattern and some sample text and see the matches highlighted instantly, which turns a famously fiddly skill into fast trial and error. This guide covers the tokens and flags you will use most.

Common tokens

Most patterns are built from a small set of building blocks:

\d any digit (0-9) \w word character (letters, digits, underscore) \s whitespace . any single character + one or more of the previous * zero or more of the previous ? zero or one (optional) ^ start of the string $ end of the string [] a set of characters, e.g. [a-z] () a group | or, e.g. cat|dog {n,m} between n and m repetitions

Flags

Flags change how the whole pattern behaves. The three you will reach for most are g (global — find all matches, not just the first), i (case-insensitive), and m (multiline, so ^ and $ match at each line break).

A worked example: matching an email

A simple email pattern combines several tokens:

^[\w.+-]+@[\w-]+\.[\w.-]+$

Read left to right: one or more word characters, dots, plus, or hyphens; an @ sign; a domain of word characters and hyphens; a literal dot (escaped as \.); and a top-level domain. The ^ and $ anchor the match to the whole string. Real-world email validation is stricter, but this pattern is a solid, readable starting point.

How to use the regex tester online

  1. Type or paste your pattern.
  2. Add flags such as g or i.
  3. Paste sample text to test against.
  4. Watch matches highlight, and refine the pattern until it fits.

Why a pattern might not match

FAQ

Q: What do the flags g, i and m do?
A: g finds every match, i ignores case, and m makes ^ and $ match at each line rather than only the start and end of the whole text.

Q: How do I match an email address?
A: A readable pattern is ^[\w.+-]+@[\w-]+\.[\w.-]+$. Fully RFC-compliant email regex is far more complex, so most apps use a simple pattern plus a confirmation step.

Q: Why is my regex not matching?
A: The usual causes are an unescaped special character, over-strict anchors, or a missing g or i flag. Testing against sample text quickly reveals which.

Use the Regex Tester