我有一个DateTime字符串ISO8601格式化
2012-10-06T04:13:00+00:00
以及与此字符串不匹配的以下正则表达式
#(\d{4})-(\d{2})-(\d{2})T(\d{2})\:(\d{2})\:(\d{2})\+(\d{2})\:(\d{2})#
我无法弄清楚为什么它不匹配.
我逃脱了元字符,对我来说似乎没问题.
编辑:
正确的方式:http://jsfiddle.net/5n5vk/3/
解决方法:
在js中指定正则表达式时不要引用正则表达式.正斜杠就足够了.
alert($('#datepicker').val());
if($('#datepicker').val().match(
/(\d{4})-(\d{2})-(\d{2})T(\d{2})\:(\d{2})\:(\d{2})[+-](\d{2})\:(\d{2})/
)) {
alert('ok');
} else {
alert('not ok');
}