简体   繁体   English

Javascript UTC匹配RegExp

[英]Javascript UTC match RegExp

I'm trying to test if passed string is matching the following format (Thu, 08 Dec 2011 18:48:38 GMT), but I really suck in regular expressions. 我正在尝试测试所传递的字符串是否与以下格式匹配(2011年12月8日,星期四,格林尼治标准时间),但是我真的很讨厌正则表达式。 Any suggestions? 有什么建议么? Thanks. 谢谢。

Here's the regular expression to test what you want: 这是测试您想要的正则表达式:

var t = newDate();
/(Mon|Tue|...|Sun)\,\s\d{2}\s(Jan|Feb|...|Dec)\s\d{4}\s\d{2}:\d{2}:\d{2}\sGMT/.test(t.toUTCString())

of course you have to replace the ... with the remaining day and month names 当然,您必须用剩余的日期和月份名称替换...

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM