Regex Tester

Test and debug regular expressions in real time — matches highlighted, groups captured

/ /

Common Patterns

Regex Quick Reference

Regular expressions have a concise syntax. \d matches any digit (0–9). \w matches any word character (letters, digits, underscore). \s matches whitespace. . matches any character except newline (use the s flag to include newlines). ^ matches the start of a line; $ matches the end.

Quantifiers control how many times something matches: + means one or more, * means zero or more, ? means zero or one, {n,m} means between n and m times. Add ? after a quantifier to make it non-greedy (match as few characters as possible).

Parentheses () create capture groups — the matched text is saved and can be referenced in replacements as $1, $2, etc. Square brackets [] define a character class: [a-z] matches any lowercase letter, [^0-9] matches anything except a digit.

Frequently Asked Questions

A pattern that describes a set of strings. Used to search, match, and replace text. \d+ matches one or more digits. [a-z]+ matches lowercase letters. .* matches anything.
g = global (find all matches). i = case-insensitive. m = multiline (^ and $ match each line). s = dotall (dot matches newlines too).
Text in parentheses () is captured for later use. (\d{4})-(\d{2}) captures year and month separately. Reference them in replacements as $1, $2.
[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,} matches most emails. Click the "Email" preset above to load it. For production, use a library — full email validation is extremely complex.