A regular-expression anchor constrains a match to a string boundary without consuming characters. Use ^ for the beginning and $ for the end. section 2.4.3
Combine anchors with a pattern when a match must occur at a specific boundary. The pattern ^hi matches text beginning with hi, task$ matches text ending with task, and ^hi task$ requires the entire string to be exactly hi task. section 2.4.3
Prefer str.startswith() or str.endswith() when the requirement is simple; use anchors with regular expressions when the boundary condition must be combined with a more complex pattern. section 2.4.3
When designing a regular-expression pattern, consider boundary anchors alongside character sets, quantifiers, groups, and named groups. section 2.6


