import re
regex = re.compile(r"^([^.0-]|[^.0-][0-9]+|[0])$", flags=re.MULTILINE)
test_str = ("111111111111111999999999999999990000000000000000333333333333333332\n"
"10\n"
"11\n"
"2\n"
"0\n"
"-1\n"
"-22\n"
"1.4\n"
"0.1\n"
"0.\n"
"0-\n"
"-0\n"
"000.4\n"
"022345\n"
"0\n")
subst = ""
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