SyntaxFix
Write A Post
Hire A Developer
Questions
Regex to the rescue!
import re s = re.sub('[^0-9a-zA-Z]+', '*', s)
Example:
>>> re.sub('[^0-9a-zA-Z]+', '*', 'h^&ell`.,|o w]{+orld') 'h*ell*o*w*orld'