fork download
  1. import re
  2. octet = r'(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)'
  3. pattern=re.compile(r"\b(?!10\.|192\.168\.|172\.(?:1[6-9]|2[0-9]|3[01])\.){0}(?:\.{0}){{3}}\b".format(octet))
  4. text = "10.11.0.0 and here are 192.168.0.0 and 192.168.0.2 145.12.24.45"
  5. print(pattern.findall(text))
  6.  
Success #stdin #stdout 0.03s 9836KB
stdin
Standard input is empty
stdout
['145.12.24.45']