Regex Tester

Test regular expressions against text live.

//g
5 matches
The Quick Brown Fox jumps over the lazy Dog.

Test regular expressions instantly, for free

Regular expressions are powerful but notoriously easy to get subtly wrong — a pattern that looks right can silently match too much, too little, or nothing at all. This free regex tester lets you paste a pattern and a block of text and immediately see every match highlighted, with flags you can toggle and capture groups broken out individually. Everything runs locally in your browser using the standard JavaScript regex engine, so what works here will work in your actual code.

What a regular expression actually is

A regular expression, or regex, is a compact pattern language for describing shapes of text rather than exact text. Instead of searching for the literal string "2026-07-10", a regex like \d{4}-\d{2}-\d{2} describes "four digits, a dash, two digits, a dash, two digits" — matching any date in that shape. That abstraction is what makes regex so useful for validating input, extracting data and searching across inconsistent text.

The flags that change how a pattern matches

A pattern behaves differently depending on which flags are switched on. g (global) tells the engine to keep searching after the first match instead of stopping there. i (case-insensitive) treats "Cat" and "cat" as identical. m (multiline) changes ^ and $ to match the start and end of every line in a multi-line string, rather than only the very start and end of the whole text. Getting these wrong is one of the most common sources of "why isn't this matching" confusion, which is exactly why the tester lets you flip them and watch the results update live.

Reading capture groups

Parentheses in a pattern create a capture group — a piece of the match you can pull out separately, such as the year in (\d{4})-\d{2}-\d{2}. This is how real code extracts specific values instead of just confirming a match exists. The tester lists each group's captured text under every match, so you can confirm your groups are grabbing exactly the substring you intend before you paste the pattern into your project.

Common patterns worth knowing

  • Digits only: ^\d+$
  • Simple email shape: ^[\w.+-]+@[\w-]+\.[a-zA-Z]{2,}$
  • Whitespace: \s+
  • A word boundary: \bword\b

How to use the tester

Type your pattern, paste your sample text, and toggle the flags you need. Matches highlight instantly as you edit either field, and any invalid pattern shows a clear syntax error instead of failing silently. Iterate until every match — and only the matches you want — is highlighted, then copy the pattern into your code with confidence.

A quick regex cheat sheet

A handful of symbols cover the vast majority of everyday patterns. . matches any single character, * means "zero or more of the previous token", + means "one or more", and ? means "zero or one", which is also how you mark a group as optional. Character classes shorten common patterns dramatically: \d matches any digit, \w matches any word character (letters, digits and underscore), and \s matches any whitespace — capitalising each one, as in \D, \W and \S, flips it to "anything but". Anchors ^ and $ pin a match to the start or end of the string (or line, with the m flag), which is essential when you need to validate that an entire value matches rather than just some substring within it. Testing a pattern against real examples — including the edge cases you expect to fail — before shipping it is the difference between a validation rule that works and one that quietly lets bad data through.

Frequently asked questions

Is my text safe if it contains sensitive data?

Yes. Matching happens entirely in your browser using JavaScript's built-in regex engine — your text and pattern are never uploaded or logged anywhere.

Which regex flavor does this tester use?

JavaScript (ECMAScript) regular expressions — the same engine used by every browser and by Node.js, so a pattern that works here will work in your code.

What do the g, i and m flags do?

g (global) finds every match instead of stopping at the first, i (case-insensitive) ignores letter case, and m (multiline) makes ^ and $ match the start and end of each line rather than the whole string.

Can I see capture groups, not just the full match?

Yes. Each match lists its numbered capture groups separately, so you can confirm the exact piece of text a group like (\d+) actually grabbed.