import re
regex = re.compile(r"""
^.[^0-9.][a-z.\s]*|(\s?[(].*?[)]|\s)$
""", flags=re.MULTILINE | re.VERBOSE)
test_str = ("Rp.1.000.005,52 (35 %)\n"
"Rp. 1.000.005,52(35 %)\n"
"Rp.1.000.005,52(35 %)\n"
"Rp. 1.000.005,52 (35 %)\n"
"asd. 1.01203102,00 (31 %)\n"
"asd. 1.01203102,00\n"
"asd. 1.01203102,00 \n"
"asd.1.01203102,00 \n"
"asd. 1.01203102,00\n"
"10120310200\n"
"1.12312309128\n"
".123123123\n"
" 12312129\n"
"12312 123123.123")
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