[import re] match or findall?

gohaku gohaku at earthlink.net
Sun Jul 4 00:02:45 CEST 2004

Hi everyone,
I am having a problem with the match function:

import re
string = 'abc 123456 xyz'
if re.match("\d{1,}",string):
         print "Found a number" #Does not print

whereas findall works:

import re
string = 'abc 123456 xyz'
if re.findall("\d{1,}",string):
         print "Found a number" #Actually prints

Is there a function similar to findall that will find the 1st 
I realize match is probably that similar function but I can't get this 
example working, for some reason.

anyone know what's wrong?

Thanks in advance.

More information about the Python-list mailing list