使用正则表达式屏蔽英文单词可以使用正则表达式 [a-zA-Z]+
匹配所有英文单词。其中,[a-zA-Z]
匹配所有大小写字母,+
表示匹配一次或多次。
如果要在文本中替换掉所有英文单词,可以使用该正则表达式进行替换,如:
import re
text = "This is a sentence with english words."
text = re.sub(r'[a-zA-Z]+','',text)
print(text)
#output :" is sentence with words."