Skip to content

Instantly share code, notes, and snippets.

@jerobado
Last active April 27, 2019 11:14
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jerobado/74a41d5a2e85f77f9c20b629d9574186 to your computer and use it in GitHub Desktop.
Save jerobado/74a41d5a2e85f77f9c20b629d9574186 to your computer and use it in GitHub Desktop.
Removes special characters in an alphanumeric text.
# Special Character Remover - removes special characters in an alphanumeric text
import string
ALPHANUMERIC = string.digits + string.ascii_letters
text = 'JI000 00-2391M/xxxx---------90234'
# output 'JI000002391Mxxxx90234'
print(''.join([char for char in text if char in ALPHANUMERIC]))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment