我在使用regex sub
从字符串中删除数字时遇到一些问题。输入字符串可以如下所示:
"The Term' means 125 years commencing on and including 01 October 2015."
"125 years commencing on 25th December 1996"
"the term of 999 years from the 1st January 2011"
我要做的是删除数字和单词'years'
-我也在使用DateFinder
来分析日期字符串,但是{
对regex
表达式删除数字和单词'years'
有什么想法吗?在
尝试删除数字和单词
years
:例如,如果:
^{pr2}$则输出为:
我想这是你想要的:
结果:
^{pr2}$注意,你最后会有一些额外的空白(也许你想要)?但你也可以把这个加到“清理”中:
因为我喜欢regex:new_item=re.sub公司(“^\s+|\s+$”,“”,新项)相关问题 更多 >
编程相关推荐