can anyone suggest me the regular expression for ip address and mac address ?
i am using python & django
for example , http://[ipaddress]/SaveData/127.0.
I need to mac address validation and I have to accept mac address without separator and with colon and dash separators. So valid formats like this
and mixed separators are invalid like this
and the validation code with regex like this.
def validate_mac_address(mac_addr):
pattern = '^(([0-9a-fA-F]{2}[:]){5}([0-9a-fA-F]{2})|([0-9a-fA-F]{2}[-]){5}([0-9a-fA-F]{2})|[0-9a-fA-F]{12})$'
return not re.match(pattern, mac_addr) is None