any86 / any-rule

🦕 常用正则大全, 支持web / vscode / idea / Alfred Workflow多平台
https://any-rule.vercel.app/
MIT License
8.53k stars 830 forks source link

我有更好的正则: 日期(严谨, 支持闰年判断) #311

Open chorar opened 6 months ago

chorar commented 6 months ago

之前的日期严格校验存在错误. image 主要存在

  1. 无法判断 0000-01-01
  2. 无法判断 1200-02-29 1600-02-29 的闰年 (严重) 可以修改成

^\d{4}-((0[13578]|1[02])-(0[1-9]|[12]\d|3[01])|(0[469]|11)-(0[1-9]|[12]\d|30)|02-(0[1-9]|1\d|2[0-8]))|(\d{2}(0[48]|[13579][26]|[2468][048])|(0[048]|[13579][26]|[2468][048])00)-02-29$ 222