php preg_replace the pattern string is different from a norm pattern.

^(19|20)\d\d[- /](0[1-9]|1[012])[- /](0[1-9]|[12][0-9]|3[01])$
this is a good pattern string for normal regexp, but if you use it directly in php (preg_match, preg_replace), you get an exception. you need to set it like:
^(19|20)\d\d[- \/](0[1-9]|1[012])[- \/](0[1-9]|[12][0-9]|3[01])$
The "/" is a special char for preg_match, you need to escape it.

评论

热门博文