节点js中的日期时间验证正则表达式 [英] Date time validation regex in node js
本文介绍了节点js中的日期时间验证正则表达式的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
需要在2015-03-18 01:00:00(年月日H:m:s)格式的node.js中验证日期时间。
任何人请帮助我,请不要给出参考链接,我已经尝试过只需要正确表达式来验证它。
Need to validate the date time in node.js in 2015-03-18 01:00:00(year-month-day H:m:s) format. Anyone please help me,please don't give reference link, I have already tried it just need regular expression which validate it.
推荐答案
您可以尝试使用 [0-9] {4} \ - (?: 0 [1-9] | 1 [0-2])\ - (?: 0 [1-9] | [1-2] [0-9] | 3 [0-1])\s +(?: 2 [0-3] | [0-1] [0-9]): 0-5] [0-9]:[0-5] [0-9]
regex。
You can try using [0-9]{4}\-(?:0[1-9]|1[0-2])\-(?:0[1-9]|[1-2][0-9]|3[0-1])\s+(?:2[0-3]|[0-1][0-9]):[0-5][0-9]:[0-5][0-9]
regex.
这是一个 regex101上的演示。
这篇关于节点js中的日期时间验证正则表达式的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文