ICode9

精准搜索请尝试: 精确搜索
首页 > 其他分享> 文章详细

正则表达式

2021-11-17 10:03:10  阅读:139  来源: 互联网

标签:REGEX String 正则表达式 zA public static final


 /* 英文单词 */
    public static final String REGEX_WORD_EN = "^\\w+$";


    /** 中文 */
    public static final String REGEX_WORD_CN = "[\u4E00-\u9FA5]+";


    /** 6到30位 数字 + 字符 + _,常用于用户名注册 */
    public static final String REGEX_WORD_EN_6_30 = "^[a-zA-Z][a-zA-Z0-9_]{6,29}$";


    /** 5到20位 数字 + 字符 + _,常用于用户名注册 */
    public static final String REGEX_WORD_EN_5_20 = "^[a-zA-Z][a-zA-Z0-9_]{5,19}$";


    /** 数字 + 字符 + _,且必须已字母开头 */
    public static final String REGEX_CHAR_NUM_UL = "^[a-zA-Z][a-zA-Z0-9_]+$";


    /** 数字 + 字母 组合 */
    public static final String REGEX_CHAR_NUM = "^[A-Za-z0-9]+$";


    /** 字母组合 */
    public static final String REGEX_CHAR = "^[A-Za-z]+$";


    /** 大写字母组合 */
    public static final String REGEX_CHAR_UC = "^[A-Z]+$";


    /** 小写字母组合 */
    public static final String REGEX_CHAR_LC = "^[a-z]+$";


    /** 双字节 */
    public static final String REGEX_DBCHAR = "[^x00-xff]+";


    /** URL地址: 包括 http, ftp 等 */
    public static final String REGEX_URL = "[a-zA-z]+://[^s]*";


    /** HTTP URL */
    public static final String REGEX_URL_HTTP = "http(s)?://[^s]+";


    /** Internet URL */
    public static final String REGEX_URL_INTERNET = "^http(s)?://([\\w-]+.)+[\\w-]+(/[\\w-./?%&=]*)?$";


    /** HTML 标签 */
    public static final String REGEX_HTML_TAG = "<(\\S*?)[^>]*>.*?|<.*? />";


    /** IP 地址 */
    public static final String REGEX_IP = "((25[0-5])|(2[0-4]\\d)|(1\\d{2})|([1-9]\\d)|(\\d)).((25[0-5])|(2[0-4]\\d)|(1\\d{2})|([1-9]\\d)|(\\d)).((25[0-5])|(2[0-4]\\d)|(1\\d{2})|([1-9]\\d)|(\\d)).((25[0-5])|(2[0-4]\\d)|(1\\d{2})|([1-9]\\d)|(\\d))";


    /** Email 地址 */
    public static final String REGEX_EMAIL = "\\w+([-+.]\\w+)*@\\w+([-.]\\w+)*.\\w+([-.]\\w+)*";


    /** 中国电话号码 */
    public static final String REGEX_PHONE_CHINA = "0\\d{2,3}-\\d{7,8}";


    /** 中国移动电话 */
    public static final String REGEX_MOBILE_CHINA = "1[3|5|8][0-9]-\\d{8}";
 

    /** 电话号码正则表达式(支持手机号码,3-4位区号,7-8位直播号码,1-4位分机号)

   匹配格式:11位手机号码 3-4位区号,7-8位直播号码,1-4位分机号  如:12345678901、1234-12345678-1234 */

    ((\d{11})|^((\d{7,8})|(\d{4}|\d{3})-(\d{7,8})|(\d{4}|\d{3})-(\d{7,8})-(\d{4}|\d{3}|\d{2}|\d{1})|(\d{7,8})-(\d{4}|\d{3}|\d{2}|\d{1}))$)

    /** 中国身份证号 */
    public static final String REGEX_IDCARD_CHINA = "\\d{17}[0-9|x|X]|\\d{15}";


    /** 中国邮政编码 */
    public static final String REGEX_ZIPCODE_CHINA = "\\d{6}";


    /** QQ号 */
    public static final String REGEX_QQ = "[1-9][0-9]{4,}";


    /** 数字 */
    public static final String REGEX_CNUMBER = "^[0-9]+$";


    /** 正数 */
    public static final String REGEX_INT_POSITIVE = "^[1-9]\\d*$";


    /** 非正数 */
    public static final String REGEX_INT_NOT_POSITIVE = "^-[1-9]\\d*|0$";


    /** 负数 */
    public static final String REGEX_INT_NEGATIVE = "^-[1-9]\\d*$";


    /** 非负数 */
    public static final String REGEX_INT_NOT_NEGATIVE = "^[1-9]\\d*|0$";


    /** 整数 */
    public static final String REGEX_CINT = "^-?[1-9]\\d*$";


    /** 浮点数 */
    public static final String REGEX_CFLOAT = "^-?([1-9]\\d*.\\d*|0.\\d*[1-9]\\d*|0?.0+|0)$";


    /** 正浮点数 */
    public static final String REGEX_FLOAT_POSITIVE = "^[1-9]\\d*.\\d*|0.\\d*[1-9]\\d*$";


    /** 非正浮点数 */
    public static final String REGEX_FLOAT_NOT_POSITIVE = "^(-([1-9]\\d*.\\d*|0.\\d*[1-9]\\d*))|0?.0+|0$";


    /** 负浮点数 */
    public static final String REGEX_FLOAT_NEGATIVE = "^-([1-9]\\d*.\\d*|0.\\d*[1-9]\\d*)$";


    /** 非负浮点数 */
    public static final String REGEX_FLOAT_NOT_NEGATIVE = "^[1-9]\\d*.\\d*|0.\\d*[1-9]\\d*|0?.0+|0$";


    /** 空行 */
    public static final String REGEX_SPACE_LINE = "\n\\s*\r";


    /** 空字符 */
    public static final String REGEX_SPACE_CHAR = "^\\s*|\\s*$";


    /**
     * 关键字标签正则:仅允许输入中文、英文(含大小写)、数字,输入内容必须以逗号隔开(含中英文逗号),但不能以逗号开头或结尾
     * 正确格式示例:99,AB,示例,ss,呵呵
     *
    public static final String REGEX_KEY_WORD_TAG = "^([a-zA-Z0-9\\u4e00-\\u9fa5]+[,|,])*[a-zA-Z0-9\\u4e00-\\u9fa5]+$";


    /**
     * 能输入有1~3位小数的正实数(包含0)
     *
     */
    public static final String REGEX_INT_ARITHMETIC_NUMBER = "^[0-9]+(\\.[0-9]{1,3})?$";
————————————————
版权声明:本文为CSDN博主「apple125414」的原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接及本声明。
原文链接:https://blog.csdn.net/apple125414/article/details/80167066

标签:REGEX,String,正则表达式,zA,public,static,final
来源: https://blog.csdn.net/baxp/article/details/121371387

本站声明: 1. iCode9 技术分享网(下文简称本站)提供的所有内容,仅供技术学习、探讨和分享;
2. 关于本站的所有留言、评论、转载及引用,纯属内容发起人的个人观点,与本站观点和立场无关;
3. 关于本站的所有言论和文字,纯属内容发起人的个人观点,与本站观点和立场无关;
4. 本站文章均是网友提供,不完全保证技术分享内容的完整性、准确性、时效性、风险性和版权归属;如您发现该文章侵犯了您的权益,可联系我们第一时间进行删除;
5. 本站为非盈利性的个人网站,所有内容不会用来进行牟利,也不会利用任何形式的广告来间接获益,纯粹是为了广大技术爱好者提供技术内容和技术思想的分享性交流网站。

专注分享技术,共同学习,共同进步。侵权联系[81616952@qq.com]

Copyright (C)ICode9.com, All Rights Reserved.

ICode9版权所有