类 RegexUtil

java.lang.Object
com.weicoder.common.util.RegexUtil
直接已知子类:
U.Regex

public class RegexUtil extends Object
用于校验字符串是否符合正则表达式
作者:
WD
  • 构造器概要

    构造器
    构造器
    说明
     
  • 方法概要

    修饰符和类型
    方法
    说明
    static boolean
    is(String[] regexs, String str)
    校验字符串
    static boolean
    is(String regex, String str)
    校验字符串
    static boolean
    字母和数值 正则表达式为 ^[a-zA-Z0-9]$
    static boolean
    字母 数值 汉字 空格 正则表达式为 ^([a-zA-Z0-9一-龥]|[_]|[ ]|[-]){1,100}$
    static boolean
    只有中文 正则表达式为 ^([一-龥]*)$
    static boolean
    联通、电信号段 正则表达式为 ^(13[0-3]|15[36]|189)(\\d){8}$
    static boolean
    日期 正则表达式为 (\\d{4})-(0[1-9]|1[0-2])-(0[1-9]|1[0-9]|2[0-9]|3[0-1])$
    static boolean
    全由数字组成 正则表达式为 ^\\d*$
    static boolean
    Email 正则表达式为 ^[\\w-]+(\\.
    static boolean
    身份证 正则表达式为 ^[\\d]{15}|[\\d]{17}[\\dxX]{1}$
    static boolean
    isIp(String str)
    IP 正则表达式为 ^\\d{1,3}\\.
    static boolean
    字母 正则表达式为 ^[a-zA-Z]+$
    static boolean
    手机 正则表达式为 ^(13[0-9]|15[0|3|6-9]|18[8|9])\\d{8}$
    static boolean
    正整数 正则表达式为 ^[0-9]*[1-9][0-9]*$
    static boolean
    校验密码
    static boolean
    电话 正则表达式为 ^[+]{0,1}(\\d){1,3}[ ]?
    static boolean
    邮政编码 正则表达式为 ^[a-zA-Z0-9 ]{3,6}$
    static boolean
    只能输入6-20个字母、数字、下划线 正则表达式为 ^(\\w){6,20}$
    static boolean
    只能含有中文和英文 正则表达式为 ^[a-zA-Z一-龥
    static boolean
    电信号段 正则表达式为 ^(133)(\\d){8}$
    static boolean
    URL 正则表达式为 ^[a-zA-z]+://(\\w+(-\\w+)*)(\\.
    static boolean
    只能输入4-18个以字母开头、可带数字、"_"的字串 正则表达式为 ^[a-zA-Z]{1}[\\w]{3,17}$

    从类继承的方法 java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • 构造器详细资料

    • RegexUtil

      public RegexUtil()
  • 方法详细资料

    • isLetters

      public static boolean isLetters(String str)
      字母 正则表达式为 ^[a-zA-Z]+$
      参数:
      str - 要验证的字符串
      返回:
      true false
    • isCUQMobile

      public static boolean isCUQMobile(String str)
      联通、电信号段 正则表达式为 ^(13[0-3]|15[36]|189)(\\d){8}$
      参数:
      str - 要验证的字符串
      返回:
      true false
    • isTELEMobile

      public static boolean isTELEMobile(String str)
      电信号段 正则表达式为 ^(133)(\\d){8}$
      参数:
      str - 要验证的字符串
      返回:
      true false
    • isRealName

      public static boolean isRealName(String str)
      只能含有中文和英文 正则表达式为 ^[a-zA-Z一-龥 .]+$
      参数:
      str - 要验证的字符串
      返回:
      true false
    • isPwd

      public static boolean isPwd(String str)
      只能输入6-20个字母、数字、下划线 正则表达式为 ^(\\w){6,20}$
      参数:
      str - 要验证的字符串
      返回:
      true false
    • isPassword

      public static boolean isPassword(String str)
      校验密码
      参数:
      str - 要验证的字符串
      返回:
      true false
    • isDate

      public static boolean isDate(String str)
      日期 正则表达式为 (\\d{4})-(0[1-9]|1[0-2])-(0[1-9]|1[0-9]|2[0-9]|3[0-1])$
      参数:
      str - 要验证的字符串
      返回:
      true false
    • isEmail

      public static boolean isEmail(String str)
      Email 正则表达式为 ^[\\w-]+(\\.[\\w-]+)*@[\\w-]+(\\.[\\w-]+)+$
      参数:
      str - 要验证的字符串
      返回:
      true false
    • isUserName

      public static boolean isUserName(String str)
      只能输入4-18个以字母开头、可带数字、"_"的字串 正则表达式为 ^[a-zA-Z]{1}[\\w]{3,17}$
      参数:
      str - 要验证的字符串
      返回:
      true false
    • isPhone

      public static boolean isPhone(String str)
      电话 正则表达式为 ^[+]{0,1}(\\d){1,3}[ ]?([-]?((\\d)|[ ]){1,12})+$
      参数:
      str - 要验证的字符串
      返回:
      true false
    • isMobile

      public static boolean isMobile(String str)
      手机 正则表达式为 ^(13[0-9]|15[0|3|6-9]|18[8|9])\\d{8}$
      参数:
      str - 要验证的字符串
      返回:
      true false
    • isPost

      public static boolean isPost(String str)
      邮政编码 正则表达式为 ^[a-zA-Z0-9 ]{3,6}$
      参数:
      str - 要验证的字符串
      返回:
      true false
    • isIp

      public static boolean isIp(String str)
      IP 正则表达式为 ^\\d{1,3}\\.\\d{1,3}\\.\\d{1,3}\\.\\d{1,3}$
      参数:
      str - 要验证的字符串
      返回:
      true false
    • isChinese

      public static boolean isChinese(String str)
      只有中文 正则表达式为 ^([一-龥]*)$
      参数:
      str - 要验证的字符串
      返回:
      true false
    • isURL

      public static boolean isURL(String str)
      URL 正则表达式为 ^[a-zA-z]+://(\\w+(-\\w+)*)(\\.(\\w+(-\\w+)*))*(\\?\\S*)?$
      参数:
      str - 要验证的字符串
      返回:
      true false
    • isDigit

      public static boolean isDigit(String str)
      全由数字组成 正则表达式为 ^\\d*$
      参数:
      str - 要验证的字符串
      返回:
      true false
    • isNumber

      public static boolean isNumber(String str)
      正整数 正则表达式为 ^[0-9]*[1-9][0-9]*$
      参数:
      str - 要验证的字符串
      返回:
      true false
    • isIdentityCardNum

      public static boolean isIdentityCardNum(String str)
      身份证 正则表达式为 ^[\\d]{15}|[\\d]{17}[\\dxX]{1}$
      参数:
      str - 要验证的字符串
      返回:
      true false
    • isChar

      public static boolean isChar(String str)
      字母和数值 正则表达式为 ^[a-zA-Z0-9]$
      参数:
      str - 要验证的字符串
      返回:
      true false
    • isCharNumber

      public static boolean isCharNumber(String str)
      字母 数值 汉字 空格 正则表达式为 ^([a-zA-Z0-9一-龥]|[_]|[ ]|[-]){1,100}$
      参数:
      str - 要验证的字符串
      返回:
      true false
    • is

      public static boolean is(String regex, String str)
      校验字符串
      参数:
      regex - 正则表达式
      str - 要验证的字符串 校验的字符串
      返回:
      true false
    • is

      public static boolean is(String[] regexs, String str)
      校验字符串
      参数:
      regexs - 正则表达式
      str - 要验证的字符串 校验的字符串
      返回:
      true false