如何确定字符串是否为日期格式? [英] How do I determine if a string is date format?

查看:122
本文介绍了如何确定字符串是否为日期格式?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一些这样的字符串: 2012-02-05T07:42:47.000Z 与其他字符串混合。此格式始终 。 (但数字不一样,当然...时代不同)
(不是$ code> Sun,05 Feb 2012 07:42:47 GMT )

I have some strings like this: 2012-02-05T07:42:47.000Z mixed with other strings. It is always in this format. (but the numbers are not the same, of course...the times are different) (not Sun, 05 Feb 2012 07:42:47 GMT)

我想知道一个字符串是否匹配该格式。我该如何确定?冒号和圆点和东西非常复杂。

I want to know whether a string matches that format. How can I determine that? It's so complicated with the colons and dots and stuff.

推荐答案

正则表达式 [0-9] {4} - [0-9] {2} [0-9] {2} T [0-9] {2}:[0-9] {2}:[0-9] {2} \。[0-9] {3} c $ c>

Regex [0-9]{4}-[0-9]{2}-[0-9]{2}T[0-9]{2}:[0-9]{2}:[0-9]{2}\.[0-9]{3}Z

这篇关于如何确定字符串是否为日期格式?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆