re.match versus re.findall
JerryB
grblanco at gmail.com
Thu Feb 9 17:34:28 EST 2006
Hi,
I have a string like this:
invalidStr = "192.168.*.1"
I want to be sure I don't get a * followed by a number, i.e. I want
invalidStr to be invalid. So I do:
numberAfterStar = re.compile(r'\*.*\d')
Now, here's the fun:
If I run:
if numberAfterStar.findall(invalidStr):
print "Found it with findall!"
it prints, if I run:
if numberAfterStar.match(invalidStr):
print "Found it with match!"
it doesn't.
Why does findall finds a match it but match doesn't?
Thanks!
Jerry
More information about the Python-list
mailing list