Skip to content

Instantly share code, notes, and snippets.

@h4ndzdatm0ld
Created May 18, 2020 23:50
Show Gist options
  • Save h4ndzdatm0ld/eea413ae2b76ee4a906a294664bd1f1d to your computer and use it in GitHub Desktop.
Save h4ndzdatm0ld/eea413ae2b76ee4a906a294664bd1f1d to your computer and use it in GitHub Desktop.
Remove Subnet Mask from IP Addy
def get_ip_only(ipadd):
''' This function will use REGEX to strip the subnet mask from an IP/MASK addy.
'''
try:
ip = re.sub(r'/.+', '', str(ipadd))
return ip
except Exception as e:
print(f"Issue striping subnetmask from {ipadd}, {e}")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment