【发布时间】:2014-01-31 22:14:16
【问题描述】:
我的 python 代码中有以下正则表达式,它真的很长。由于 python 是一种以空格分隔的语言,我该如何清理它?
matches = re.findall("((?:jan(?:(?:.)?|(?:uary)?)|feb(?:(?:.)?|(?:ruary)?)|mar(?:(?:.)?|(?:ch)?)|apr(?:(?:.)?|(?:il)?)|may|jun(?:(?:.)?|(?:e)?)|jul(?:(?:.)?|(?:y)?)|aug(?:(?:.)?|(?:gust)?)|sep(?:(?:.)?|(?:ept(?:(?:.)?))?|(?:tember)?)|oct(?:(?:.)?|(?:ober)?)|nov(?:(?:.)?|(?:ember)?)|dec(?:(?:.)?|(?:ember)?)) (?:[12][0-9]|[1-9]))",fileText,re.IGNORECASE)
任何帮助将不胜感激。
【问题讨论】:
-
请您解释一下该模式的逻辑。这种模式的正则表达式应该捕捉到什么?
标签: python regex python-2.7