Skip to content

Instantly share code, notes, and snippets.

@arush-sal
Created December 14, 2021 09:15
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save arush-sal/801a2486036dfdb558f899d4ba2af72c to your computer and use it in GitHub Desktop.
Save arush-sal/801a2486036dfdb558f899d4ba2af72c to your computer and use it in GitHub Desktop.
IPv4 Socket Address Regex
def is_ipv4_socket_address(network):
return re.match(r"^(([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])\.){3}([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5]):([0-9]{1,4}|[1-5][0-9]{4}|6[0-4][0-9]{3}|65[0-4][0-9]{2}|655[0-2][0-9]|6553[0-5])$",network)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment