Developer & PM Utility

Regex Tester

Test a regular expression against sample text with live highlighting, match indices, and capture groups.

Matches
Highlighted matches will appear here
Match Details
Match groups and indices will appear here

Test regular expressions live

Type a pattern and a test string and see matches highlighted instantly, along with each match's index and any capture groups. This uses JavaScript's native RegExp engine, so behavior matches exactly what you'll get in browser JS or Node.js.

Flag reference

  • g (global): Find all matches instead of stopping at the first one.
  • i (ignore case): Match letters regardless of case.
  • m (multiline): Make ^ and $ match the start/end of each line, not just the whole string.
  • s (dotAll): Let . match newline characters too.
  • u (unicode): Treat the pattern as a sequence of Unicode code points, important for correctly matching emoji and characters outside the Basic Multilingual Plane.

Quick syntax cheatsheet

PatternMeaning
.Any character except newline
\d \w \sDigit, word character, whitespace
\D \W \SNegated versions of the above
* + ?0 or more, 1 or more, 0 or 1
{n,m}Between n and m repetitions
^ $Start / end of string (or line, with m)
(...)Capture group
(?:...)Non-capturing group
(?<name>...)Named capture group
a|bAlternation (a or b)
\bWord boundary

Common patterns you can copy

What it matchesPattern
Email address (basic)\b[\w.+-]+@[\w-]+\.[a-zA-Z]{2,}\b
US phone number\(?\d{3}\)?[-.\s]?\d{3}[-.\s]?\d{4}
URL (basic)https?:\/\/[^\s]+
Hex color code#[0-9a-fA-F]{6}\b
Whole number (integer)-?\d+
Leading/trailing whitespace^\s+|\s+$
Multiple consecutive spaces\s{2,}
Words starting with a capital letter\b[A-Z][a-z]*\b

These cover the common case, not every edge case in each format's full specification. For anything where correctness genuinely matters (like validating an email before storing it), pair a regex sanity-check with a stronger confirmation step, like actually sending a verification email.

New to regex? Start here

If the syntax above looks unfamiliar, our beginner's guide to regular expressions builds up from single characters to full patterns like the email example above, explaining what each piece does along the way.

Frequently Asked Questions

Your browser's native JavaScript RegExp engine — the same one used in Node.js and every modern browser — so behavior matches your actual runtime exactly.
They will — named groups defined with (?<name>...) are listed alongside numbered groups in the match details, labeled with their name.
Make sure the g (global) flag is checked. Without it, JavaScript's RegExp stops after the first match.
No, matching runs entirely in your browser using JavaScript's built-in regex engine.
By default, quantifiers like * and + are greedy — they match as much text as possible. Adding a ? after one (like *?) makes it lazy, matching as little as possible instead. This matters most when matching something bounded by delimiters, like text inside quotes, where greedy matching can accidentally span further than intended.
Different regex engines (JavaScript, Python's re, PCRE used by many other languages) have small syntax and behavior differences, particularly around lookbehind support and some escape sequences. This tool specifically uses JavaScript's engine, so if you're writing a pattern for another language, double check the equivalent syntax there too.
Escape it with a backslash. To match a literal period, use \. instead of . (which otherwise matches any character). The same applies to \(, \), \[, \], \{, \}, \+, \*, \?, and a few others.