English 中文(简体)
一种限定日期,在RegEx进行试验
原标题:One type of delimiter in one date time string in RegEx

是否有办法只写一个限定日期,才能确认某种限制?

例如,第30/04/2010号是正确的,但第30-04/2010号是不正确的。

我 go笑了,发现了一些背靠道的情况,但我不清楚如何使用。 例如,如果具备这一规定:

http://www.un.org/? iii

那么,我为什么要在这里使用回轨?

非常感谢。

最佳回答

您没有回答问题,但您是否考虑使用strtotime()。

这是一种非常灵活的功能,能够规定任何公务员的日期和时间:

Feb 2, 2010
February 2, 2010
02/02/10
4 weeks ago
Next Monday

如果日期无法分开,则该功能将在PHP 5之前恢复<代码>false(或-1)。

有几个信道——我认为我记得,在使用<条码>xx-xx时,它倾向于假定一个欧元的<代码>DD-MM-YYYYYY日期——但毕竟,你可能比起一个格列。

问题回答

虽然Pekka的答复能更好地解决你的问题,但我认为应该回答你的这一部分问题:

那么,我为什么要在这里使用回轨?

这方面的实例与“05-07-2010”和“05/07/2010”相吻合,但并非“05-07/2010”:

"#^d{2}([/-])d{2}1d{4}$#"
        ------     --

栏目中最重要的部分为:<代码>1。 下面是第一部捕获子主<代码>([/-])Back参引

The regex you have, seems to check the string is in any of the possible formats that a datetime can be. If you just want to check for your given example 30/04/2010 you could use this easy one

([d]{1,2})/([d]{1,2})/([d]{2,4})

(日数和月数1-2位数,年数2-4位数)





相关问题
Mysql compaire two dates from datetime?

I was try to measure what is faster and what should be the best way to compare two dates, from datetime record in MySql db. There are several approaches how to grab a date from date time, but I was ...

iPhone Date Picker rolls over to 2010 on December 27th?

So I implemented a UIDatepicker in one of my applications for scheduling and autodialing teleconferences... everything is pretty much ready to go except, while testing I noticed that when the date ...

Convert date Python

I have MMDDYY dates, i.e. today is 111609 How do I convert this to 11/16/2009, in Python?

specifying date format when using $form->inputs() in CakePHP

I am wondering if there is a way to specify the date format in the forms created using CakePHP s $form->inputs(); Please note that this is not the individual $form->input() but instead $form->inputs() ...

NSDateFormat, super simple! Where am I screwing up?

Ok, this is really simple, maybe I m a getting a bit burnt out, but seems like it should work, Query XML feed, put out date string, format, display in a cell. The issue is I m a getting a NULL ...

sqlite writing a date into an email

I am exporting a date value from sqlite and placing it into an email. The date appears like this 279498721.322872 I am using Objective C in an Iphone App. Does anyone know how to make this export ...

热门标签