Next / Previous / Contents / Shipman's homepage

9.6. FLOAT_PATTERN

A regular expression that matches valid floats.

logscan.py
FLOAT_REGEX = (INT_REGEX +
    r'('              # Start optional fraction group
      r'\.'             # Decimal point
      r'\d*'            # Zero or more digits after it
    r')?')           # Whole group is optional
FLOAT_PATTERN = re.compile(FLOAT_REGEX)