123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153 |
- <?php
- /**
- * Created by PhpStorm.
- * User: wangyachao
- * Time: 15:15
- */
- namespace common\helpers;
- 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}|[0-9]{16}([0-9]|X|x))$/";
- /**
- * 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|14|15|17|18)[0-9]{9}$/';
- /**
- * 电话或者手机
- * @var string
- */
- public static $telormobile = '/^1\d{10}$|^(0\d{2,3}-?|\(0\d{2,3}\))?[1-9]\d{4,7}(-\d{1,8})?$/';
- /**
- * 电话号
- */
- 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}$/";
- }
|