Woooowen You can do anything you set your mind to, man

常用正则验证

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)$/";

    public static $decmal4 = "/^[1-9]\\d*.\\d*|0.\\d*[1-9]\\d*|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+$/";

    public static $num1 = "/^[1-9]\\d*|0$/";

    public static $num2 = "/^-[1-9]\\d*|0$/";

    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})$/";

    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)$/";

    public static $qq = "/^[1-9]*[1-9][0-9]*$/";

    public static $rar = "(.*)\\.(rar|zip|7zip|tgz)$/";

    public static $url = "^http[s]? = \\/\\/([\\w-]+\\.)+[\\w-]+([\\w-./?%&=]*)?$/";

    public static $username = "/^[A-Za-z0-9_\\-\\u4e00-\\u9fa5]+$/";

    public static $zipcode = "/^\\d{6}$/";

}

Woooowen 浙ICP备15013647号