Test and debug regular expressions with live matching and explanations.
Flags:
Enter your regex in the pattern field. Use the reference tables below if you need help with metacharacters, quantifiers, or flags. The pattern updates matching in real time.
Paste the string you want to match against. All matches are highlighted instantly. Use the global flag (g) to find all matches, or remove it to match only the first occurrence.
Adjust your pattern until you get the matches you need. Check capture groups to extract specific parts. Copy the final pattern into your code.
| Character | Meaning | Example | Matches |
|---|---|---|---|
| . | Any character except newline | c.t | "cat", "cut", "c3t" |
| ^ | Start of string | ^Hello | "Hello world" (at start) |
| $ | End of string | world$ | "Hello world" (at end) |
| * | Zero or more | ab*c | "ac", "abc", "abbc" |
| + | One or more | ab+c | "abc", "abbc" (not "ac") |
| ? | Zero or one (optional) | colou?r | "color" and "colour" |
| {n} | Exactly n times | \d{4} | Exactly 4 digits |
| {n,m} | Between n and m times | \d{2,4} | 2 to 4 digits |
| [abc] | Any one of a, b, c | [aeiou] | Any vowel |
| [^abc] | Not a, b, or c | [^0-9] | Any non-digit |
| (abc) | Capture group | (\d+) | Captures one or more digits |
| a|b | a or b | cat|dog | "cat" or "dog" |
| \d | Any digit [0-9] | \d+ | One or more digits |
| \w | Word char [a-zA-Z0-9_] | \w+ | One or more word chars |
| \s | Whitespace | \s+ | One or more spaces/tabs |
| \b | Word boundary | \bword\b | Whole word "word" only |
/^[\w.-]+@[\w.-]+\.[a-z]{2,}$/i/^\+?1?[-.\s]?\(?\d{3}\)?[-.\s]?\d{3}[-.\s]?\d{4}$//https?:\/\/(www\.)?[-a-zA-Z0-9@:%._+~#=]{1,256}\.[a-zA-Z]{2,6}//^(\d{1,3}\.){3}\d{1,3}$//^#([A-Fa-f0-9]{6}|[A-Fa-f0-9]{3})$//^\d{4}-(0[1-9]|1[0-2])-(0[1-9]|[12]\d|3[01])$//^(?=.*[a-z])(?=.*[A-Z])(?=.*\d)(?=.*[@$!%*?&])[A-Za-z\d@$!%*?&]{8,}$//^\d+$/g — GlobalFind all matches in the string, not just the first. Without g, only the first match is returned.
i — Case-insensitiveMakes the match ignore upper/lower case. /hello/i matches "Hello", "HELLO", and "hello".
m — MultilineMakes ^ and $ match the start/end of each line, not just the whole string.
s — dotAllMakes . match any character including newlines. Without s, . does not match \n.
Common questions about Regex Tester