+2 votes
in Programming Languages by (71.8k points)
edited by

I have strings like this - Chashme Baddoor Full Songs ★ JUKEBOX ★ Ali Zafar, Divyendu Sharma, Siddharth. I want to remove all non-alphanumeric characters from it. How can I do it in python?

1 Answer

+3 votes
by (71.8k points)
selected by
 
Best answer

Best way is to use regular expression. Check this example.

import re

s ='Chashme Baddoor Full Songs ★ JUKEBOX ★ Ali Zafar, Divyendu Sharma, Siddharth'

s = re.sub('[^0-9a-zA-Z ]+', '', s)


...