Test, debug, and build regular expressions with real-time match highlighting, capture groups, and replace. Runs entirely in your browser.
Run a regex with capture groups to see results here.
. Any character\\w Word [a-zA-Z0-9_]\\d Digit [0-9]\\s Whitespace\\W Non-word\\D Non-digit\\S Non-whitespace* 0 or more+ 1 or more? 0 or 1{n} Exactly n{n,} n or more{n,m} Between n and m*? Lazy (non-greedy)^ Start of string$ End of string\\b Word boundary(abc) Capture group(?:abc) Non-capturing(?=abc) Lookahead(?<=abc) Lookbehind[abc] a, b, or c[^abc] Not a, b, or c[a-z] a to z[A-Z] A to Z[0-9] 0 to 9a|b a or b\\ Escape charJSON Formatter, JWT Decoder, Hash Generator, UUID Generator, and 25+ more tools.
Browse All Tools →Regular expressions (regex) are patterns used to match character combinations in strings. This tool lets you write, test, and debug regex patterns instantly with real-time match highlighting.
// Test a pattern
const regex = /(\w+)@(\w+)\.(\w+)/g;
const text = "user@example.com";
const matches = text.matchAll(regex);
for (const match of matches) {
console.log(match[0]); // Full match: user@example.com
console.log(match[1]); // Group 1: user
console.log(match[2]); // Group 2: example
console.log(match[3]); // Group 3: com
}
// Replace with groups
const result = text.replace(regex, '$1 [at] $2 [dot] $3');
// → "user [at] example [dot] com"
/^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}$/ — Email validation/^https?:\/\/[^\s]+$/ — URL validation/^\d{4}-\d{2}-\d{2}$/ — Date format (YYYY-MM-DD)/^(?=.*[a-z])(?=.*[A-Z])(?=.*\d).{8,}$/ — Strong password/^\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}$/ — IPv4 addressg (Global) — Find all matches, not just the firsti (Case-insensitive) — Match regardless of casem (Multiline) — ^ and $ match start/end of each lines (Dotall) — . matches newline charactersu (Unicode) — Enable full Unicode matchingPaste your regex pattern into the pattern field and your test string into the text area. Matches are highlighted in real-time as you type. You can see capture groups, match positions, and all matches in the results panel. Toggle flags like global (g), case-insensitive (i), and multiline (m) as needed.
Regex flags modify how pattern matching works. Common flags: g (global) finds all matches instead of stopping at the first; i (case-insensitive) treats uppercase and lowercase as equal; m (multiline) makes ^ and $ match line starts/ends; s (dotAll) makes . match newlines.
A capture group is a portion of the regex pattern wrapped in parentheses () that captures the matched text for later use. For example, (\d{4})-(\d{2})-(\d{2}) matches a date and captures year, month, and day in separate groups. Named groups use the syntax (?<name>pattern).
A simple email regex is /^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}$/. However, perfectly validating email addresses with regex is notoriously difficult. For production use, send a verification email rather than relying solely on regex validation, as the email spec allows many unusual formats.
Greedy matching (default) tries to match as much text as possible. .* in <b>text</b> would match the entire string including tags. Lazy matching (.*?) matches as little as possible. In the same example, <.*?> would match just <b>. Use lazy quantifiers when you need to match the shortest possible string.
Explore the MatrixClawAI API — automate your workflow with AI agents.
Explore API →