import re
regex = re.compile(r"\b(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9]?[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9]?[0-9])\b")
test_str = ("67.93.195.181\n"
"248.83.55.126\n"
"277.92.425.12\n"
"220.164.237.203\n"
"36.173.112.111\n"
"36.33.171.246\n"
"37.123.14.323\n"
"23.93.163.86\n"
"236.129.173.89\n"
"2.224.237.202\n"
"256.123.123.123\n"
"69.10.174.79\n"
"35.185.155.175\n"
"6.215.157.157\n"
"123.123.123.234\n"
"188.43.121.96\n"
"101.22.3.71\n"
"1.1.1.1\n"
"55.58.142.177\n"
"179.107.91.118")
matches = regex.finditer(test_str)
for match_num, match in enumerate(matches, start=1):
print(f"Match {match_num} was found at {match.start()}-{match.end()}: {match.group()}")
for group_num, group in enumerate(match.groups(), start=1):
print(f"Group {group_num} found at {match.start(group_num)}-{match.end(group_num)}: {group}")
Please keep in mind that these code samples are automatically generated and are not guaranteed to work. If you find any syntax errors, feel free to submit a bug report. For a full regex reference for Python, please visit: https://docs.python.org/3/library/re.html