I have the string "The dog has 12.345 bones". I want to match 12.345 and replace its . with XYZ such that the string becomes "The dog has 12XYZ345 bones". The number could be any valid number which has thousand-dots, so 1, 456, 1.000 or 34.234.233. E.g., 100.00 is not valid. How would I do that?
For internet addresses I used
address_pattern = r"(www).([A-Za-z0-9]*)\.(de|com|org)"
re.sub(address_pattern, r"\XYZ\2XYZ\3", text)
but the issue is, numbers can be as long as they want, I don't have an exact amount of groups to replace with.