import re
regex = re.compile(r"^(?:\D+)?(?:(?:[5-6](?:(?:\.|\,)[1-9])?)|(?:[6-7](?:(?:\.|\,)0)?))(?:(?:\s?pol)|\"|''|\x60|'|´|”)?(?:.*)", flags=re.DOTALL)
test_str = ("4.5 polegadas (~ 64,3% relação tela-corpo)\n\n"
"5,5 polegadas super amoled full hd, 1080p 401 ppi corning® gorilla® glass 3\n\n"
"5,5 polegadas super amoled full hd, 1080p 401 ppi corning® gorilla® glass 3\n\n"
"5\"-6\" polegadas super amoled full hd, 1080p 401 ppi corning® gorilla® glass 3\n\n"
"^(?:(6(?:\\.|\\,)0)|(5(?:\\.|\\,)[1-9]))(.*)\n"
"\\s?(?:(?:\\d+)(?:\\.|\\,)?(?:\\d+)?)(?:\"|''|\\x60|'|´|”)\n\n"
"(?:(5(?:\\.|\\,)0)|(4(?:\\.|\\,)[1-9]))(.*)\n\n"
"(4(?:\\.|\\,)[1-9])(.*) => 4-5\n"
"(5(?:\\.|\\,)[0]))(.*) => 4-5")
match = regex.search(test_str)
if match:
print(f"Match 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