Home  >  Article  >  php教程  >  php正则匹配字符串中是否有日期数据

php正则匹配字符串中是否有日期数据

WBOY
WBOYOriginal
2016-06-13 10:14:281829browse

我们今天来讲述一个超级简单有实用的实例就是告诉你如何利用preg_match函数正匹配字符串是否有我们想要的内容,下面我们以匹配日期为实例吧。

 代码如下 复制代码
if(preg_match("/d{4}-d{2}-d{2}/","开始大幅拉萨大家2012-02-02 12:12:12舍得离开房间")){
echo 'ye';
}else{
echo 'no';
}

?>
Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn