regular expression for integer and decimal numbers

Andrew Dalke adalke at mindspring.com
Fri Sep 24 01:39:38 EDT 2004


Andrew Durdin wrote:
> That will work for numbers such as 0123  12.345  12.  0.5 -- but it
> won't work for the following:
> 0x12AB  .5  10e-3  -15  123L

This will handle the normal floats including a leading + or -
and trailing exponent, all optional.

r"[+-]?((\d+(\.\d*)?)|\.\d+)([eE][+-]?[0-9]+)?"

				Andrew
				dalke at dalkescientific.com



More information about the Python-list mailing list