收集起来的一些常用的正则验证
2012-12-03 16:41
232 查看
class Regexp { //put your code here /** * 验证真实姓名 */ public static $realname = '/^[A-Za-z0-9\\u4e00-\\u9fa5]+$/'; /** * 浮点数 */ public static $decmal = "/^([+-]?)\\d*\\.\\d+$/"; /** * 正浮点数 */ public static $decmal1 = "/^[1-9]\\d*.\\d*|0.\\d*[1-9]\\d*$/"; /** * 负浮点数 */ public static $decmal2 = "/^-([1-9]\\d*.\\d*|0.\\d*[1-9]\\d*)$/"; /** * 浮点数 */ public static $decmal3 = "/^-?([1-9]\\d*.\\d*|0.\\d*[1-9]\\d*|0?.0+|0)$/"; /** * 非负浮点数(正浮点数 + 0) */ public static $decmal4 = "/^[1-9]\\d*.\\d*|0.\\d*[1-9]\\d*|0?.0+|0$"; /** * 非正浮点数(负浮点数 + 0) */ public static $decmal5 = "/^(-([1-9]\\d*.\\d*|0.\\d*[1-9]\\d*))|0?.0+|0$/"; /** * 整数 */ public static $intege = "/^-?[1-9]\\d*$/"; /** * 正整数 */ public static $intege1 = "/^[1-9]\\d*$/"; /* * 负整数 */ public static $intege2 = "/^-[1-9]\\d*$/"; /** * 数字 */ public static $num = "/^([+-]?)\\d*\\.?\\d+$/"; /** * 正数(正整数 + 0) */ public static $num1 = "/^[1-9]\\d*|0$/"; /** * 负数(负整数 + 0) */ public static $num2 = "/^-[1-9]\\d*|0$/"; /** * 仅ACSII字符 */ public static $ascii = "/^[\\x00-\\xFF]+$/"; /** * 仅中文 */ public static $chinese = "/^[\\u4e00-\\u9fa5]+$/"; /** * 颜色 */ public static $color = "/^[a-fA-F0-9]{6}$/"; /** * 日期 */ public static $date = "/^\\d{4}(\\-|\\/|\.)\\d{1,2}\\1\\d{1,2}$/"; /** * 邮件 */ public static $email = "/^\\w+((-\\w+)|(\\.\\w+))*\\@[A-Za-z0-9]+((\\.|-)[A-Za-z0-9]+)*\\.[A-Za-z0-9]+$/"; /** * 身份证 */ public static $idcard = "/^[1-9]([0-9]{14}|[0-9]{17})$/"; /** * ip地址 */ public static $ip4 = "/^(25[0-5]|2[0-4]\\d|[0-1]\\d{2}|[1-9]?\\d)\\.(25[0-5]|2[0-4]\\d|[0-1]\\d{2}|[1-9]?\\d)\\.(25[0-5]|2[0-4]\\d|[0-1]\\d{2}|[1-9]?\\d)\\.(25[0-5]|2[0-4]\\d|[0-1]\\d{2}|[1-9]?\\d)$/"; /** * 字母 */ public static $letter = "/^[A-Za-z]+$/"; /** * 小写字母 */ public static $letter_l = "/^[a-z]+$/"; /** * 大写字母 */ public static $letter_u = "/^[A-Z]+$/"; /** * 手机 */ public static $mobile = '/(13|15)[0-9]{9}$/'; /** * 电话号 */ public static $tel = "/(^(86)\-(0\d{2,3})\-(\d{7,8})\-(\d{1,4})$)|(^0(\d{2,3})\-(\d{7,8})$)|(^0(\d{2,3})\-(\d{7,8})\-(\d{1,4})$)|(^(86)\-(\d{3,4})\-(\d{7,8})$)/"; /** * 非空 */ public static $notempty = "/^\\S+$/"; /** * 密码 */ public static $password = "/^[A-Za-z0-9_-]+$/"; /** * 图片 */ public static $picture = "(.*)\\.(jpg|bmp|gif|ico|pcx|jpeg|tif|png|raw|tga)$/"; /* * QQ号码 */ public static $qq = "/^[1-9]*[1-9][0-9]*$/"; /** * 压缩文件 */ public static $rar = "(.*)\\.(rar|zip|7zip|tgz)$/"; /** * url */ public static $url = "^http[s]? = \\/\\/([\\w-]+\\.)+[\\w-]+([\\w-./?%&=]*)?$/"; /** * 用户名 */ public static $username = "/^[A-Za-z0-9_\\-\\u4e00-\\u9fa5]+$/"; /** * 邮编 */ public static $zipcode = "/^\\d{6}$/"; }
相关文章推荐
- 一些表单验证常用的正则表达式收集
- 一些表单验证常用的正则表达式收集
- 一些表单验证常用的正则表达式收集
- JQuery入门常用的一些方法、表单操作、正则验证
- 日期验证 正则表达式及一些常用正则(全部搜集与网络)
- C#代码实现邮箱验证C#中及一些常用的正则表达式
- 收集一些常用的正则表达式
- 常用的一些正则验证
- 收集一些常用的php正则表达式
- 收集一些常用的正则表达式
- 收集一些常用的正则表达式
- 收集一些常用的正则表达式
- 收集一些常用的正则表达式(匹配中文字符、匹配双字节字符、匹配HTML标记、匹配空行 and so on~~~)
- C#代码实现邮箱验证C#中及一些常用的正则表达式
- 收集的一些正则表达式的验证
- 一些常用的正则表达式(个人收集)
- 验证控件中一些常用的正则表达式
- C#代码实现邮箱验证C#中及一些常用的正则表达式
- 收集一些常用的正则表达式。
- 收集一些常用的正则表达式