Next / Previous / Contents / Shipman's homepage

9.5. INT_PATTERN

A regular expression that matches valid integers.

logscan.py
INT_REGEX = (
    r'\s*'            # Ignore leading whitespace
    r'([\-+]?\s*)'    # Optional sign and following whitespace
    r'\d+')          # One or more digits left of decimal
INT_PATTERN = re.compile(INT_REGEX)