python - How to use regex to remove all symbols but replace blank with '-' -
i know regex, example
re.sub(r'[^\w]', '', string)
i can remove symbols string. want remove other symbols replace blank '-'. there way that?
for example,
string = "felix's 3d's" # want "felixs-3d"
thanks!
if want replace spaces -
ignore , str.replace:
print(re.sub(r'[^\w\s]', '',string).replace(" ","-")) felixs-3ds