How to remove the characters specified in a pattern from a string using regex in Python

1 Answer

0 votes
import re

s = "Python! [is> an interpreted high-level? general-purpose *programming @language."

s = re.sub(r"""[!?'".<>(){}@%&*/[/]""", "", s)

print(s)



'''
run:

Python is an interpreted high-level general-purpose programming language

'''

 



answered Apr 29, 2021 by avibootz
...