Developer & PM Utility
Test a regular expression against sample text with live highlighting, match indices, and capture groups.
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.
^ and $ match the start/end of each line, not just the whole string.. match newline characters too.| Pattern | Meaning |
|---|---|
. | Any character except newline |
\d \w \s | Digit, word character, whitespace |
\D \W \S | Negated 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|b | Alternation (a or b) |
\b | Word boundary |
| What it matches | Pattern |
|---|---|
| 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.
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.
RegExp engine — the same one used in Node.js and every modern browser — so behavior matches your actual runtime exactly.(?<name>...) are listed alongside numbered groups in the match details, labeled with their name.RegExp stops after the first match.* 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.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.\. instead of . (which otherwise matches any character). The same applies to \(, \), \[, \], \{, \}, \+, \*, \?, and a few others.