(original) (raw)
Hi Jeff,
>At 10:29 PM 6/29/2004, Jeff Peery wrote:
>>hello I am having trouble with using the re module. I have a statement:
>>
>>line = FileHandle.readline(-1)
>>test = findall('\d', line)
>>
>>where "line" is a line of text from a file I would like
to read and
>>extract numbers from. the line is simply three numbers, example
>>3.444456 4 84.3546354. I want to put
these number in "test" but the
>>findall expression seems to only take whole numbers, so for example
test
>>would be for the above numbers [3, 4, 4, 4, 4, 5, 6, 4, 8, ....].
How is
>>this done so that test = [3.444456 4 84.3546354]?
>
>
>>>> re.findall(r'\d+.?\d*', '3.444456
4 84.3546354')
>['3.444456', '4 ', '84.3546354']
I fell that, you are looking for
this:
>>> re.findall('\S+',
'3.444456 4 84.3546354')
['3.444456', '4', '84.3546354']
Yours sincerely,
J�nos Juh�sz