Skip to content

Instantly share code, notes, and snippets.

@augustogoulart
Created May 5, 2017 01:17
Show Gist options
  • Save augustogoulart/b9023335088ed10f623e0d8b908c3a5b to your computer and use it in GitHub Desktop.
Save augustogoulart/b9023335088ed10f623e0d8b908c3a5b to your computer and use it in GitHub Desktop.
ipv4 regex
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