regular expressions and matches
exter_c at hotmail.com
Thu Mar 30 11:48:58 CEST 2006
I have recently written a small function that will verify that an IP
address is valid.
ipAddress = raw_input('IP Address : ')
re_ip = re.compile(ipRegex)
match = re_ip.match(ipAddress)
if not match:
print "an error has occured with ipAddress"
I was having issues trying to get my code working so that I could pass
the IP addresses and it would return a true or false. When it matches I
get something that looks like this.
IP Address : 220.127.116.11
<_sre.SRE_Match object at 0xb7de8c80>
As I am still attempting to learn python I am interested to know how I
could get the above to return a true or false if it matches or does not
match the IP address. I would also like to expand that so that if the
IP is wrong it requests the IP address again and recalls the function.
I have done the same thing in php very easily but python appears to be
getting the better of me. Any assistance and advice would be greatly
More information about the Python-list