Regex Tester

Test a JavaScript regular expression against real text, live.

/ /

Test a regular expression against sample text with live highlighting of matches and capture groups, using JavaScript's native regex engine.

How to use the regex tester

  1. Type a pattern without the surrounding slashes — for example \d{3}-\d{4}.
  2. Add flags such as g to find every match, or i to ignore case.
  3. Paste test text. Matches are highlighted as you type, and capture groups are listed for each match.

Regex cheat sheet

PatternMatches
.Any character except a line break
\d / \w / \sA digit / a letter, digit or underscore / whitespace
[abc] / [^abc]One of a, b or c / any character except those
* / + / ?0 or more / 1 or more / 0 or 1 of the previous item
{3} / {2,5}Exactly 3 / between 2 and 5 of the previous item
^ / $Start / end of the text (or of each line with the m flag)
(...)A capture group
a|ba or b
\bA word boundary

Flags

  • g — global: find all matches, not just the first
  • i — ignore uppercase and lowercase differences
  • m — multiline: ^ and $ match at each line
  • s — lets . match line breaks too
  • u — full Unicode support, for emoji and other scripts

Useful patterns to start from

FindPattern
US ZIP code (12345 or 12345-6789)\b\d{5}(-\d{4})?\b
US phone number like 555-123-4567\b\d{3}-\d{3}-\d{4}\b
Date like 2026-11-02\d{4}-\d{2}-\d{2}
Simple email address[\w.+-]+@[\w-]+\.[\w.]+

These are starting points, not complete validators — real email addresses in particular have many edge cases.

Frequently asked questions

What regex flavor does this use?

JavaScript's native regular expression engine — the same one used in browser JavaScript, Node.js, and most modern web frameworks.

Is my test text sent anywhere?

No — matching runs entirely in your browser using the built-in RegExp object.

Why does my pattern only find one match?

Add the g (global) flag. Without it, JavaScript stops after the first match.

How do I match a special character like . or ?

Put a backslash in front of it. For example, \. matches a literal period and \? matches a question mark.