1判决原告在1999年6月至2001年2月和2002年5月共计22个月期间与被告存在劳动关系;1依法确认原告与被告自2011年12月26日至2019年10月13日存在劳动关系;依法确认原、被双方自1995年1月至2009年12月存在劳动关系。自2000年7月1日至2001年7月31日之间存在劳动关系使用python写一个通用的正则表达式提取四段文本中的年月日
import re
text1 = '1.判决原告在1999年6月至2001年2月和2002年5月,共计22个月期间与被告存在劳动关系;' text2 = '1.依法确认原告与被告自2011年12月26日至2019年10月13日存在劳动关系;' text3 = '依法确认原、被双方自1995年1月至2009年12月存在劳动关系。' text4 = '自2000年7月1日至2001年7月31日之间存在劳动关系'
pattern = r'(\d{4}年\d{1,2}月\d{1,2}日)'
match1 = re.findall(pattern, text1) match2 = re.findall(pattern, text2) match3 = re.findall(pattern, text3) match4 = re.findall(pattern, text4)
print(match1) print(match2) print(match3) print(match4)
原文地址: https://www.cveoy.top/t/topic/gAHu 著作权归作者所有。请勿转载和采集!