RosettaCodeData/Task/Determine-if-a-string-is-nu.../Python/determine-if-a-string-is-nu...

6 lines
147 B
Python

import re
numeric = re.compile('[-+]?(\d+(\.\d*)?|\.\d+)([eE][-+]?\d+)?')
is_numeric = lambda x: numeric.fullmatch(x) != None
is_numeric('123.0')