Home > Backend Development > PHP Tutorial > 关于日期正则表达式解决思路

关于日期正则表达式解决思路

WBOY
Release: 2016-06-13 10:36:02
Original
979 people have browsed it

关于日期正则表达式
猫了个咪哟!!正则表达式真难学!!!苦涩难懂啊!!!


$str="~2012-3-1+2012-12-31+14200++";

$flag=ereg("([0-9]{4})-([0-9]{1,2})-([0-9]{1,2})", $v, $regs);


 $flag=ereg("~([0-9]{4})-([0-9]{1,2})-([0-9]{1,2})", $v, $regs);


这么写并没区别啊,同样都会返回 flag 是正数,

为什么会没区别啊?

 $flag=ereg("~([0-9]{4})-([0-9]{1,2})-([0-9]{1,2})\+$", $v, $regs);

这么写为啥又不能返回 flag 为正值啊?



------解决方案--------------------
为什么会没区别啊?

 $flag=ereg("~([0-9]{4})-([0-9]{1,2})-([0-9]{1,2})\\+$", $v, $regs);

这么写为啥又不能返回 flag 为正值啊?
------解决方案--------------------

探讨

为什么会没区别啊?

$flag=ereg("~([0-9]{4})-([0-9]{1,2})-([0-9]{1,2})\\+$", $v, $regs);

这么写为啥又不能返回 flag 为正值啊?
Related labels:
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template