我需要从日志文件中删除独立编号。例如。从右侧删除所有以1个空格+ 1个数字开头的内容。
"process: 123" => text = "process:"
遵循正则表达式可以完成工作:
^(?P<text>.*)\s\d
但是,如果没有空格+数字,则我的正则表达式什么也不会返回。如何扩展我的解决方案以满足以下3个要求?
"process: 123" => text = "process:"
"node4" => text = "node4"
"text without number" => text = "text without number"