如何使用 Python 正则表达式匹配除空格和换行符之外的任何内容?
pythonserver side programmingprogramming更新于 2025/7/4 9:48:17
以下代码使用正则表达式匹配给定字符串中除空格和换行符之外的任何内容。
示例
import re print re.match(r'^[^ \n]*$', """IfindTutorialspointuseful""") print re.match(r'^[^ \n]*$', """I find Tutorialspointuseful""") print re.match(r'^[^ \n]*$', """Ifind Tutorialspointuseful""")
输出
这给出了输出
<_sre.SRE_Match object at 0x00000000048965E0> None None
相关文章
有用资源
python 参考教程 - 该教程包含有关 python 的更多信息:https://www.cainiaomax.com/python/

