Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/289.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
python正则表达式,删除除\d\s\w之外的所有_Python_Regex - Fatal编程技术网

python正则表达式,删除除\d\s\w之外的所有

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'[^.,

如何制作一个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'[^.,\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