From D

Alex Martelli aleax at
Tue Jul 31 17:52:26 CEST 2007

mensanator at <mensanator at> wrote:

> code files? What's the regular expression for
> locating a number with an arbitrary number of digits
> seperated into an arbitrary number of blocks of an
> arbitray number of digits with an arbitrary number
> of whitespace characters between each block?

For a decimal integer (or octal) number, I'd use something similar to:

This also gets trailing whitespace, but that shouldn't be much of a
problem in most practical cases.  Of course, just like today, it becomes
a bit hairier if you also want to find hex, oct (to be 0o777 in the
future), other future notations such as binary, floats, complex numbers,
&c:-) -- but the simple fact that a [\d\s] is accepted where today only
a \d would be, per se, would not contribute to that hair in any
significant way, it seems to me.


More information about the Python-list mailing list