Created
June 14, 2017 10:27
-
-
Save scottwallacesh/ebe04c7c26e08d7895175de137898e08 to your computer and use it in GitHub Desktop.
Small Python function to validate an IP address
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def is_valid_ip(ip): | |
m = re.match(r"^(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})$", ip) | |
return bool(m) and all(map(lambda n: 0 <= int(n) <= 255, m.groups())) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment