m/ ^ # anchor to the beginning of the string -? # 0 or 1 dashes (for negative numbers I assume) \.? # 0 or 1 decimal points \d+ # 1 or more numbers (?:\.\d+)? # 0 or 1 decimal places followed by a number $ # anchor to the end of the string /x