[Solved] How to search a document for IP addresses [closed]
If your addresses are always on the end of a line, then anchor on that: ip_at_end = re.compile(r'(?:[0-9]{1,3}\.){3}[0-9]{1,3}$’, re.MULTILINE) This regular expression only matches dotted quads (4 sets of digits with dots in between) at the end of a line. Demo: >>> import re >>> ip_at_end = re.compile(r'(?:[0-9]{1,3}\.){3}[0-9]{1,3}$’, re.MULTILINE) >>> example=””‘\ … Only addresses on … Read more