正则表达式,用于匹配和替换标点符号,数字和特殊字符

时间:2019-05-21 05:17:02

标签: regex python-3.x

我正在寻找一个用python编写的正则表达式,以从文本中删除标点符号,数字和符号(例如$-。,@等),并将文本也转换为小写。

示例文本为:

I'm looking for text without the given numbers like 123, $223.423 ab-c@cde. Is it possible with the python regular expression?

输出文本为:

i looking for text without the given numbers like is it possible with the python regular expression

1 个答案:

答案 0 :(得分:0)

ss = "I'm looking for text without the given numbers like 123, $223.423 ab-c@cde. Is it possible with the python regular expression?"
ss1 = ''.join([i for i in ss if i.isalpha() or i == " "]).replace("   "," ").lower()
print(ss1)

输出:

im looking for text without the given numbers like abccde is it possible with the python regular expression

享受