JENKINS中我的MM / DD / YYYY正则表达式有什么问题

问题描述 投票:0回答:2

我需要以MM / DD / YYYY验证日期格式。在我的情况下,Null也有效。这是我的正则表达式[0-9]{2}\/[0-9]{2}\/[0-9]{4}$ |

下图显示了使用我的正则表达式的作业配置

Jenkins config

错误

Job error

regex date jenkins date-format
2个回答
0
投票

我将原件修改为此:

^(?:(?:(?:0?[13578]|1[02]|(?:Jan|Mar|May|Jul|Aug|Oct|Dec))(\/|-|\.)31)\1|(?:(?:0?[1,3-9]|1[0-2]|(?:Jan|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec))(\/|-|\.)(?:29|30)\2))(?:(?:1[6-9]|[2-9]\d)?\d{2})$|^(?:(?:0?2|(?:Feb))(\/|-|\.)(?:29)\3(?:(?:(?:1[6-9]|[2-9]\d)?(?:0[48]|[2468][048]|[13579][26])|(?:(?:16|[2468][048]|[3579][26])00))))$|^(?:(?:0?[1-9]|(?:Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep))|(?:1[0-2]|(?:Oct|Nov|Dec)))(\/|-|\.)(?:0?[1-9]|1\d|2[0-8])\4(?:(?:1[6-9]|[2-9]\d)?\d{2})$

Test the regex here


0
投票

我将使用以下方法进行初始验证

^[0-9]{2}\/[0-9]{2}\/[0-9]{4}$

我添加了^来指示字符串的开头,并且从原始正则表达式的末尾删除了|(它是联合运算符,或)。我测试了它here

© www.soinside.com 2019 - 2024. All rights reserved.