Skip to content

Instantly share code, notes, and snippets.

@dardanxhymshiti
Last active July 3, 2020 14:34
Show Gist options
  • Save dardanxhymshiti/66854e6e545b6464e549ec13b29f92b5 to your computer and use it in GitHub Desktop.
Save dardanxhymshiti/66854e6e545b6464e549ec13b29f92b5 to your computer and use it in GitHub Desktop.
def remove_punctuation_marks(text):
import string
import re
pattern = f'[%s]' % re.escape(string.punctuation)
text_wo_punctuation_marks = re.sub(pattern, '', text)
return text_wo_punctuation_marks
# Test
text = """Hello, World!"""
remove_punctuation_marks(text)
# 'Hello World'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment