我正在尝试扫描一些文档以查找分类问题的日期。在阅读了这里和其他一些地方之后,我构建了以下正则表达式
months='['+'|'.join(calendar.month_abbr[1:])+'|'+'|'.join(calendar.month_name[1:])+']'
techPart='+\\.*\\s*\\d{1,2}[,]?[\\s*][1|2]\\d{3}'
dateExpr=months+techPart
我正在这个字符串上测试它
newString='Mar. 31, 2011 Dec. 31, 2010 bananas Mar. 31, 2011 too much malarky September 1, 1992 redundant Dec. 31, 2010 September 29, 1999 March 12 2004 ddfd March. 13 2019 ddfd Mac. 13 2019 ddfd'
当我像这样运行它时
for date in re.findall(dateExpr,newString):
print date
我明白了
Mar. 31, 2011
Dec. 31, 2010
Mar. 31, 2011
September 1, 1992
Dec. 31, 2010
September 29, 1999
March 12 2004
March. 13 2019
Mac. 13 2019 #here is my problem