On 01/04/17 00:35, Ed Manning wrote:
> 
> What's the best way to validate a string contains a IP address 

It depends on how thorough you want to be.
You can define a regex to check that its 4 groups of numbers
separated by periods.

Or you can split the string into fields and validate that
the values are each less than 255

Or you could try connecting to it and see if you get a
response...

How sure do you need to be?

-- 
Alan G
Author of the Learn to Program web site
http://www.alan-g.me.uk/
http://www.amazon.com/author/alan_gauld
Follow my photo-blog on Flickr at:
http://www.flickr.com/photos/alangauldphotos


_______________________________________________
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor

Reply via email to