Home > php教程 > PHP源码 > body text

ThinkPHP 自动验证匹配a-z0-9_(下划线) 再加上-(减号)

PHP中文网
Release: 2016-05-25 16:59:13
Original
1470 people have browsed it

原始正则验证如下:
array('name', '/^[a-z]\w{2,10}$/i', '格式错误.'),
原匹配不包含-(减号), 因为某些原因需要需要使用-(减号).
修改成如下:
array('name', '/^[a-z][a-z0-9\_\-]{2,10}$/i', '格式错误.'),
可以匹配-减号. ThinkPHP PHParray('name', '/^[a-z][a-z0-9\_\-]{2,10}$/i', '格式错误.'),

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 Recommendations
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!