[英]I have an problem at hand on regular expressions in Javascript
var pattern = /[AZ][az]{2}-\d{2}-\d{4}/
This is the pattern, I have used to match the date string of format Jan-12-2000
var pattern = /[AZ][az]{2}-\d{2}-\d{4}/
这是模式,我用来匹配格式为Jan-12-2000
的日期字符串
Problem is I need the pattern for following strings,问题是我需要跟随字符串的模式,
I am really stuck at this trying so many options not getting exact result.我真的被困在这个尝试了这么多选择而没有得到确切结果的过程中。 Really appreciate if somebody could provide the solution.
如果有人可以提供解决方案,我真的很感激。
const rgx = /([AZ][az]{2,3}[-\s,])?\d{2,4}([-\s,]\d{4})?/; console.log(rgx.test('Jan-12-2000')) console.log(rgx.test('Jul 23, 2020')) console.log(rgx.test('Jul 23')) console.log(rgx.test('Jul 2020')) console.log(rgx.test('23, 2020'))
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.