exp = "(d{1,3}.){3}d{1,3}" ip = "blah blah 192.168.0.185 blah blah" match = re.search(exp, ip) print match.group()