Developer Guide
Regex Cheat Sheet
Regular expression syntax reference: character classes, quantifiers, anchors, groups, and lookahead. Copy-paste regex patterns.
Quick reference for regular expression syntax. Test patterns in the Regex Tester.
Character classes
. = any char except newline. \d = digit [0-9]. \D = non-digit. \w = word char [A-Za-z0-9_]. \W = non-word. \s = whitespace. \S = non-whitespace. [abc] = a, b, or c. [^abc] = not a, b, or c. [a-z] = range.
Anchors
^ = start of string/line. $ = end of string/line. \b = word boundary. \B = non-word boundary. Example: ^hello matches "hello world" but not "say hello".
Quantifiers
* = 0 or more. + = 1 or more. ? = 0 or 1. {n} = exactly n. {n,} = n or more. {n,m} = between n and m. Add ? for non-greedy: *? +? {n,m}?
Groups and references
(abc) = capturing group. (?:abc) = non-capturing group. \1, \2 = backreference to group 1, 2. (?<name>abc) = named group (flavor-dependent).
Common patterns
Email: [a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}. URL: https?://[\S]+. Phone (US): \d{3}-\d{3}-\d{4}. UUID: [0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}
Summary
Test your regex patterns in the Regex Tester to see matches highlighted in real-time.