Python Regular Expression

A Regular Expression, is a sequence of characters that forms a search pattern. Python has a built-in package called re, which can be used to work with Regular Expressions.

(Example Code to remove symbols and numbers - compatible with Python 2.7.17)
import re
import string
input_str = "58597884|01:31:50|The rise of python stated by pythonforengineers blog"
print"Before Processing:",input_str
result = re.sub(r'\d+', '', input_str)
result = result.translate(string.maketrans("",""), string.punctuation)
print"After Processing:",result

No comments: