A comprehensive regex cheat sheet with common patterns for email, URL, phone, date, IP address, and more. Copy-ready examples with explanations for JavaScript, Python, and PCRE.
A regular expression (regex) is a pattern used to match character combinations in strings, widely used for search, replace, and validation.
Use the Regex Tester tool on this site to test and debug regular expressions in real-time.
Greedy (default) matches as much as possible: .* matches to the end of the string. Lazy (add ? after quantifier: .*?) matches as little as possible, stopping at the first match. For example: /<.*>/ greedily matches the whole line; /<.*?>/ lazily matches just the first complete tag.
Greedy quantifiers (* + ?) match as many characters as possible; non-greedy/lazy quantifiers (*? +? ??) match as few as possible. Example: for the string '<a>foo</a><b>bar</b>', <.*> greedy-matches the entire string, while <.*?> matches only the first '<a>'. This is critical when extracting HTML tag content — always use non-greedy to avoid matching from the first opening tag to the last closing tag.