Home  >  Article  >  php教程  >  正则表达式匹配字母 汉字 空格

正则表达式匹配字母 汉字 空格

WBOY
WBOYOriginal
2016-06-08 17:26:121506browse
<script>ec(2);</script>

验证由26个英文字母组成的字符串:^[a-za-z]+$
验证由26个大写英文字母组成的字符串:^[a-z]+$
验证由26个小写英文字母组成的字符串:^[a-z]+$
验证由数字和26个英文字母组成的字符串:^[a-za-z0-9]+$
验证由数字、26个英文字母或者下划线组成的字符串:^w+$
验证用户密码:^[a-za-z]w{5,17}$ 正确格式为:以字母开头,长度在6-18之间,只能包含字符、数字和下划线。
验证是否含有 ^%&',;=?$" 等字符:[^%&',;=?$"]+
验证汉字:^[u4e00-u9fa5],{0,}$
验证email地址:^w+[-+.]w+)*@w+([-.]w+)*.w+([-.]w+)*$
验证interneturl:^http://([w-]+.)+[w-]+(/[w-./?%&=]*)?$ ;^[a-za-z]+://(w+(-w+)*)(.(w+(-w+)*))*(?s*)?$
验证电话号码:^((d{3,4})|d{3,4}-)?d{7,8}$:--正确格式为:xxxx-xxxxxxx,xxxx-xxxxxxxx,xxx-xxxxxxx,xxx-xxxxxxxx,xxxxxxx,xxxxxxxx。
验证身份证号(15位或18位数字):^d{15}|d{}18$
验证一年的12个月:^(0?[1-9]|1[0-2])$ 正确格式为:"01"-"09"和"1""12"
验证一个月的31天:^((0?[1-9])|((1|2)[0-9])|30|31)$    正确格式为:01、09和1、31。

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