我在Python中验证这种类型的输入字符串时遇到了问题。
工作日的字符数可变。
Regular: 16Mar2009(mon), 17Mar2009(tues), 18Mar2009(wed)
Regular: 20Mar2009(fri), 21Mar2009(sat), 22Mar2009(sun)
Rewards: 26Mar2009(thur), 27Mar2009(fri), 28Mar2009(sat)
我想验证整行,每一行都应该有这种特定的格式:
<name>: <date>(<weekday>), <date>(<weekday>), <date>(<weekday>)
提前致谢!
答案 0 :(得分:-1)
试试这个:
if re.search(r"[\d]{1,2}[a-z]{3}[\d]{4}\([a-z]{3,4}\)", string, re.IGNORECASE):
# Successful match
else:
# Match attempt failed