Next / Previous / Contents / Shipman's homepage

10.3. YEAR_PAT: Pattern for year numbers

This pattern matches year numbers in the range 1000-2999. The '$' character is the end-of-line anchor, and matches only at the end of a string.

YEAR_PAT  =  re.compile (
    r'[12]'       # First digit must be 1 or 2
    r'\d{3}'      # Followed by three more digits
    r'$' )        # Insure that the entire string was matched