python正则表达式,删除除\d\s\w之外的所有
如何制作一个python正则表达式,除去文本中的所有字符:python正则表达式,删除除\d\s\w之外的所有,python,regex,Python,Regex,如何制作一个python正则表达式,除去文本中的所有字符:\d\w\s 我试过这样的方法: import re re.sub(r'\W*\D*\S*', '', 'this is my<\n test <+-,1345.;>') 重新导入 re.sub(r'\W*\D*\S*','',这是我的使用倒排字符类: re.sub(r'[^., \t\w]*', '', 'this is my<\n test <+-,1345.;>') re.sub(r'[^.,
\d\w\s
我试过这样的方法:
import re
re.sub(r'\W*\D*\S*', '', 'this is my<\n test <+-,1345.;>')
重新导入
re.sub(r'\W*\D*\S*','',这是我的使用倒排字符类:
re.sub(r'[^., \t\w]*', '', 'this is my<\n test <+-,1345.;>')
re.sub(r'[^.,\t\w]*,'',这是我的使用倒排字符类:
re.sub(r'[^., \t\w]*', '', 'this is my<\n test <+-,1345.;>')
re.sub(r'[^,\t\w]*,'',这是myand如何删除\n并保留.and,@gurehbgui:replace\s
为一个文本空格和一个\t
选项卡(因此删除\n
匹配项),并将标点添加到反向类中:[^,\t\w\d]
以及如何删除\n并保留.and,?gurehbgui:用文本空格和\t
选项卡替换\s
(因此删除\n
匹配项),并将标点添加到反向类:[^,\t\w\d]
您的字符类相互抵消。\w
已经包括\d
,不需要在此显示\d
。您的字符类相互抵消。\w
已经包括\d
,不需要在此显示\d
。