正则表达式问题 [英] Regular Expression Problem

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

问题描述

Hiya all,


我正在尝试验证php中的日期,例如2006年9月12日。但是,出于某种原因,以下正则表达式不起作用。

Hiya all,

I''m trying to validate a date in php to be in the form 12-Sep-2006 for example. However, for some reason the following regex wont work.

展开 | 选择 | Wrap | 行号

推荐答案

Heya,William。


而不是使用正则表达式,尝试使用strtotime():
Heya, William.

Instead of using a regular expression, try using strtotime():
展开 | 选择 | Wrap | 行号


另一件事是你应该使用preg_match()而不是ereg()。
Another thing is that you should be using preg_match() not ereg().


对不起,我试过了使用preg_match()但它没有任何区别,我没有看到strtodate将如何以任何方式帮助我。


我使用它作为验证器将日期保留在表格中13- 2007年9月。


谢谢。
Sorry, I have tried using preg_match() but it makes no difference and I do not see how strtodate will help me in any way.

I am using this as a validator to keep dates in the form 13-Sep-2007.

Thanks.


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

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