I am a big fan of regular expressions, which is why I am so disappointed the Python builtin re module has such weak support for Unicode categories. Fortunately, it is quite common that people will bundle regex · PyPI with their Python deployments, including Esri.
Using regex instead of re allows for people to use Unicode categories to write regular expressions that are much more portable in this global world we live in:
import regex
def remove_alpha(value):
return regex.sub("[^\p{NUMBER}\p{DASH}]", "", str(value))