import re p = "123.45$" result = re.sub(r"[^0-9]", "", p) print(result)
12345