[Tutor] Amazing power of Regular Expressions...
ajkadri at googlemail.com
Sat Nov 4 16:46:22 CET 2006
I dont know much about Regular Expressions. But I just want to share my
I was trying to implement error checking code on the date argument:
I did this:
# the user should enter date in the format: dd/mm/yyyy
p = re.compile('\d\d/\d\d/\d\d\d\d')
m = p.match(date)
the function match will return an object of type SRE_Match only if the user
has supplied the string in the form of dd/mm/yyyy. If the user tries to
supply negative values, then match will return None.
So no hassle of using all those Ifs and Elifs........
I think REGULAR Expressions can be quite powerful...
To HIM you shall return.
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the Tutor