import re
regex = re.compile(r"^(0|[1-9][0-9]{0,8}|[1-3][0-9]{9}|4[01][0-9]{8}|42[0-8][0-9]{7}|429[0-3][0-9]{6}|4294[0-8][0-9]{5}|42949[0-5][0-9]{4}|429496[0-6][0-9]{3}|4294967[0-1][0-9]{2}|42949672[0-8][0-9]|429496729[0-5])$", flags=re.MULTILINE)
test_str = ("0\n"
"1\n"
"2\n"
"123\n"
"999999999\n"
"1000000000\n"
"2000000000\n"
"3000000000\n"
"4000000000\n"
"5000000000\n"
"4500000000\n"
"4250000000\n"
"4270000000\n"
"4280000000\n"
"4290000000\n"
"4300000000\n"
"4295000000\n"
"4294000000\n"
"4294500000\n"
"4294600000\n"
"4294700000\n"
"4294800000\n"
"4294900000\n"
"4294950000\n"
"4294960000\n"
"4294970000\n"
"4294965000\n"
"4294966000\n"
"4294967000\n"
"4294968000\n"
"4294967500\n"
"4294967400\n"
"4294967300\n"
"4294967200\n"
"4294967250\n"
"4294967270\n"
"4294967290\n"
"4294967295\n"
"4294967296\n"
"1\n"
"0\n"
"-1\n"
"-4294967295\n\n")
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