remove_punctuation
- pyhelpers.text.remove_punctuation(x, rm_whitespace=True)[source]
Remove punctuation from string-type data.
- Parameters:
x (str) – raw string-type data
rm_whitespace (bool) – whether to remove whitespace (incl. escape characters), defaults to
True
- Returns:
text with punctuation removed
- Return type:
str
Examples:
>>> from pyhelpers.text import remove_punctuation >>> raw_text = 'Hello world! This is a test. :-)' >>> text = remove_punctuation(raw_text) >>> text 'Hello world This is a test' >>> text = remove_punctuation(raw_text, rm_whitespace=False) >>> text 'Hello world This is a test'