Created
May 5, 2017 01:17
-
-
Save augustogoulart/b9023335088ed10f623e0d8b908c3a5b to your computer and use it in GitHub Desktop.
ipv4 regex
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
import re | |
ip = "1.2.3.4" | |
ipregex = re.compile("^\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}$") | |
test = ipregex.match(ip) | |
if test: | |
print("Valid") | |
else: | |
print("Not valid") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment