import re
regex = re.compile(r"((\d*,*\d*\d)\\)|(\d*,\d*)|((\d*)\/)", flags=re.MULTILINE)
test_str = ("1,258\\xa0sq\\xa0mi (3,260\\xa0km2)\n"
"45\\xa0sq\\xa0mi (120\\xa0km2) \\xa03.6%\n"
"234,878\n"
"45\\xa0sq\\xa0mi (120\\xa0km2) \\xa03.6%\n"
"194/sq\\xa0mi (75/km2\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