正则表达式检查Actionscript中的日期3 [英] Regular Expression to check Date in Actionscript 3

查看:92
本文介绍了正则表达式检查Actionscript中的日期3的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,



我正在Flash Builder 4.6中开发一个应用程序,在我的应用程序中我有TextInput字段来从用户那里获取日期。我想以这种格式得到它:yyyy / mm / dd如2013/09/24

那么,我的正则表达式应该是什么来检查是否提交了上述格式的正确日期? ?

我的textinput字段id是date



我在我的actionscript函数中得到它的价值:



var d_date:String = new String;

d_date = date.text.toString();



现在我想检查这个d_date是否是yyyy / mm / dd格式?

有什么建议吗?

感谢您的帮助...

Hi every one,

I am developing an application in Flash Builder 4.6 and in my Application I have TextInput field to get the date from user. I wanna get it in this format: yyyy/mm/dd like 2013/09/24
So, what should be my regular expression to check if a correct date in the above format is submitted or not??
my textinput field id is "date"

And I am getting its value in my actionscript function like this:

var d_date:String = new String;
d_date = date.text.toString();

Now I wanna check this d_date if it is in yyyy/mm/dd format?
Any suggestions??
Thanks for any help...

推荐答案

我能给出的最好的建议是:不要使用正则表达式。

一定要用一个基本的正则表达式来检查四个-digits斜杠后两位斜杠两位数字;这很简单:

The best suggestion I can give is: don't use a regex for this.
By all means use a basic regex to check four-digits-slash-two-digits-slash-two-digits; thats simple:
^\d{4}/\d\d/\d\d


但不要试图进一步。这真的不值得:检查并转换代码中的实际日期,这很多,很简单!

But do not try to take it any further. It really isn't worth it: check and convert the actual date in code, it is a lot, lot simpler!


这篇关于正则表达式检查Actionscript中的日期3的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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