regular expression for integer and decimal numbers
gary
gary.wilson at gmail.com
Sat Sep 25 16:13:22 EDT 2004
Peter Hansen <peter at engcorp.com> wrote in message news:<pbadnZrDHOinY87cRVn-jg at powergate.ca>...
> gary wrote:
> > I want to pick all intergers and decimal numbers out of a string.
> > Would this be the most correct regular expression to use?
> >
> > "\d+\.?\d*"
>
> Examples, including the most extreme cases you want to handle,
> are always a good idea.
>
> -Peter
Here is an example of what I will be dealing with:
"""
TOTAL FIRST DOWNS 19 21
By Rushing 11 6
By Passing 6 10
By Penalty 2 5
THIRD DOWN EFFICIENCY 4-11-36% 6-14-43%
FOURTH DOWN EFFICIENCY 0-1-0% 0-0-0%
TOTAL NET YARDS 379 271
Total Offensive Plays (inc. times thrown passing) 58 63
Average gain per offensive play 6.5 4.3
NET YARDS RUSHING 264 115
"""
I can only hope that they were nice and put a leading zero in front of
numbers less than 1.
More information about the Python-list
mailing list