【发布时间】:2012-10-13 22:04:33
【问题描述】:
这里是正则表达式新手。我有如下文字:
"Show title 2012 23 10 this is its title"
我需要一个正则表达式来匹配日期之后的所有内容:
"this is its title"
【问题讨论】:
标签: regex regex-negation
这里是正则表达式新手。我有如下文字:
"Show title 2012 23 10 this is its title"
我需要一个正则表达式来匹配日期之后的所有内容:
"this is its title"
【问题讨论】:
标签: regex regex-negation
Show title 2012 23 10 \Kthis is its title
另一种表示法是:
(?<!Show title 2012 23 10)this is its title
参见http://www.perlmonks.org/?node_id=518444(这是 Perl,但适用于大多数现代语言)
如果你需要更简单的东西,你应该说你使用的是什么语言。
【讨论】:
在python中,
import re
dateformat = re.compile(r'\d{4} \d{1,2} \d{1,2}')
dateformat.split('Show title 2012 23 10 this is its title')[1].strip()
会给你输出。
您可以将日期格式修改为您可以预期的正则表达式。
【讨论】:
"Show title 2012 23 10 this is its title"[22:] 的东西就可以应用于 yahoo 管道。