import re
regex = re.compile(r"(?<=[^\W\d_]{7})[^\W\d_]{1,3}\b", flags=re.MULTILINE | re.UNICODE)
test_str = ("253. Ficam revogadas a Lei nº 1.711, de 28 de outubro de 1952, e respectiva legislação complementar, bem como as demais disposições em contrário.\n\n"
"foooooo\n"
"fooooooo\n"
"foooooooo\n"
"fooooooooo\n"
"foooooooooo\n"
"fooooooooooo")
subst = "[\\g<0>]"
result = regex.sub(subst, test_str)
if result:
print(result)
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