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.
consider s=256.1.1.1 i'd like to make a little modification from Michal's answer:
def find_ip(s):
part = '(2[0-4]|1[0-9]|[0-9])?[0-9]|25[0-5]'
res =re.search(r'(^| )((%s)\.){3}(%s)' %(part,part), s,re.I )
if res:
return res.group().strip()
else:
return ''
notice '(^| )' means line start or space ahead, to avoid get '56.1.1.1' from '256.1.1.1'