Anchors, quantifiers, groups, lookaheads, and real-world patterns.
^ and $/^Hello$/m // matches "Hello" on its own line\b and \B/\bcat\b/ // "cat" but NOT "concatenate"\A and \Z (PCRE)/\Astart.*end\Z/s // Python/PHP strict anchoring\G (continuation)/\G\d+,/ // matches each number+comma in a sequence* + ? {n,m}/<.+>/ // greedy: matches entire "<b>text</b>"*? +? ?? {n,m}?/<.+?>/ // lazy: matches just "<b>"*+ ++ (Possessive)/\d++[abc]/ // PCRE: no backtracking after digits match{3} exactly / {3,} at least/\d{4}-\d{2}-\d{2}/ // strict date format YYYY-MM-DD(abc) — Capturing group/(foo|bar)/ // captures "foo" or "bar" in group 1(?:abc) — Non-capturing/(?:https?|ftp):\/\// // groups protocol options without capture(?<name>abc) — Named group/(?<year>\d{4})-(?<month>\d{2})/.exec(s).groups.year\1 \2 (Backreference)/(['"])[^\1]*\1/ // match string with matching quotes(?| branch reset)/(?|(cat)|(dog))/ // both alternatives are group 1(?(1)yes|no) — Conditional/(<)?word(?(1)>)/ // optionally match word in angle brackets(?=abc) — Positive lookahead/\d+(?= dollars)/ // matches "100" in "100 dollars"(?!abc) — Negative lookahead/^(?!.*admin).*$/ // strings that don't contain "admin"(?<=abc) — Positive lookbehind/(?<=\$)\d+/ // matches digits after a dollar sign(?<!abc) — Negative lookbehind/(?<!\d)\d{4}/ // 4-digit num NOT preceded by another digitg i m s u/pattern/gim // all matches, case-insensitive, multi-line\d \w \s \D \W \S/^\w+@\w+\.\w{2,}$/ // simple email pattern[abc] / [^abc] / [a-z0-9]/[a-zA-Z0-9_-]{3,20}/ // valid username pattern\p{L} \p{N} (Unicode)/\p{Emoji_Presentation}/gu // match emoji characters(?x) verbose modere.compile(r"(?x) \d{4} # year \- \d{2} # month")Email validation/^[a-zA-Z0-9._%+\-]+@[a-zA-Z0-9.\-]+\.[a-zA-Z]{2,}$/URL matching/https?:\/\/(www\.)?[-\w@:%.\+~#=]{1,256}\.[a-z]{2,6}\b[-\w@:%\+.~#?&=]*/iStrong password/^(?=.*[a-z])(?=.*[A-Z])(?=.*\d)(?=.*[@$!%*?&]).{8,}$/IPv4 address/^((25[0-5]|2[0-4]\d|[01]?\d\d?)\.){3}(25[0-5]|2[0-4]\d|[01]?\d\d?)$/Semantic Version/^(0|[1-9]\d*)\.(0|[1-9]\d*)\.(0|[1-9]\d*)(?:-([\w.-]+))?(?:\+([\w.-]+))?$/Slug / URL-safe string/^[a-z0-9]+(?:-[a-z0-9]+)*$/ // "my-post-slug"