【发布时间】:2017-11-06 07:38:05
【问题描述】:
考虑到text = "car price is $2017 and manufactured in 2017 and make is Honda",我正在尝试编写一个匹配第二个 2017 年(制造年)的正则表达式。为此,我使用了否定的lookbehind模式,但匹配的字符串始终是第一个 2017。
我使用的代码是re.search('(?<!\$)2017', text).group(),也使用了re.search('(?<!$)2017', text).group()(没有\)但没有成功。
任何指向我做错了什么的指针。
【问题讨论】:
-
没什么错,first regex is matching
2017that has no$in front,正是您所需要的。
标签: python regex python-2.7