当前位置:网站首页>Common regular expressions
Common regular expressions
2022-04-23 07:22:00 【dotphoenix】
package com.modules.plateform.tool; import java.util.regex.Pattern; /** * Account related attribute verification tool * */ public class AccountValidatorUtil { /** * Regular expressions : Verify user name */ public static final String REGEX_USERNAME = "^[a-zA-Z]\\w{5,20}$"; /** * Regular expressions : Verify password */ public static final String REGEX_PASSWORD = "^[a-zA-Z0-9]{6,20}$"; /** * Regular expressions : Verify phone number */ public static final String REGEX_MOBILE = "^((17[0-9])|(14[0-9])|(13[0-9])|(15[^4,\\D])|(18[0,5-9]))\\d{8}$"; /** * Regular expressions : Verify email */ public static final String REGEX_EMAIL = "^([a-z0-9A-Z]+[-|\\.]?)+[a-z0-9A-Z]@([a-z0-9A-Z]+(-[a-z0-9A-Z]+)?\\.)+[a-zA-Z]{2,}$"; /** * Regular expressions : Verify Chinese characters */ public static final String REGEX_CHINESE = "^[\u4e00-\u9fa5],{0,}$"; /** * Regular expressions : Verify ID card */ public static final String REGEX_ID_CARD = "(^\\d{18}$)|(^\\d{15}$)"; /** * Regular expressions : verification URL */ public static final String REGEX_URL = "http(s)?://([\\w-]+\\.)+[\\w-]+(/[\\w- ./?%&=]*)?"; /** * Regular expressions : verification IP Address */ public static final String REGEX_IP_ADDR = "(25[0-5]|2[0-4]\\d|[0-1]\\d{2}|[1-9]?\\d)"; /** * Verify username * * @param username * @return Verify by returning true, Otherwise return to false */ public static boolean isUsername(String username) { return Pattern.matches(REGEX_USERNAME, username); } /** * Check the password * * @param password * @return Verify by returning true, Otherwise return to false */ public static boolean isPassword(String password) { return Pattern.matches(REGEX_PASSWORD, password); } /** * Check cell phone number * * @param mobile * @return Verify by returning true, Otherwise return to false */ public static boolean isMobile(String mobile) { return Pattern.matches(REGEX_MOBILE, mobile); } /** * Checkbox * * @param email * @return Verify by returning true, Otherwise return to false */ public static boolean isEmail(String email) { return Pattern.matches(REGEX_EMAIL, email); } /** * Check Chinese characters * * @param chinese * @return Verify by returning true, Otherwise return to false */ public static boolean isChinese(String chinese) { return Pattern.matches(REGEX_CHINESE, chinese); } /** * Check ID card * * @param idCard * @return Verify by returning true, Otherwise return to false */ public static boolean isIDCard(String idCard) { return Pattern.matches(REGEX_ID_CARD, idCard); } /** * check URL * * @param url * @return Verify by returning true, Otherwise return to false */ public static boolean isUrl(String url) { return Pattern.matches(REGEX_URL, url); } /** * check IP Address * * @param ipAddr * @return */ public static boolean isIPAddr(String ipAddr) { return Pattern.matches(REGEX_IP_ADDR, ipAddr); } }
版权声明
本文为[dotphoenix]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/04/202204230609059462.html
边栏推荐
- Component based learning (3) path and group annotations in arouter
- Write a wechat double open gadget to your girlfriend
- [point cloud series] a rotation invariant framework for deep point cloud analysis
- 素数求解的n种境界
- Exploration of SendMessage principle of advanced handler
- [dynamic programming] different binary search trees
- MySQL notes 4_ Primary key auto_increment
- 三子棋小游戏
- 【点云系列】Fully-Convolutional geometric features
- MySQL notes 3_ Restraint_ Primary key constraint
猜你喜欢
PyMySQL连接数据库
【2021年新书推荐】Red Hat Certified Engineer (RHCE) Study Guide
第5 章 机器学习基础
Visual studio 2019 installation and use
Chapter 5 fundamentals of machine learning
Pymysql connection database
【点云系列】Learning Representations and Generative Models for 3D pointclouds
【点云系列】Relationship-based Point Cloud Completion
Raspberry Pie: two color LED lamp experiment
【3D形状重建系列】Implicit Functions in Feature Space for 3D Shape Reconstruction and Completion
随机推荐
Raspberry Pie: two color LED lamp experiment
WebView displays a blank due to a certificate problem
扫雷小游戏
Visual studio 2019 installation and use
Gee configuring local development environment
MySQL数据库安装与配置详解
c语言编写一个猜数字游戏编写
【点云系列】FoldingNet:Point Cloud Auto encoder via Deep Grid Deformation
Computer shutdown program
第2章 Pytorch基础2
Project, how to package
【动态规划】不同的二叉搜索树
MySQL5. 7 insert Chinese data and report an error: ` incorrect string value: '\ xb8 \ XDF \ AE \ xf9 \ X80 at row 1`
深度学习模型压缩与加速技术(一):参数剪枝
cmder中文乱码问题
Keras如何保存、加载Keras模型
Fill the network gap
[dynamic programming] different paths 2
【指标】Precision、Recall
【2021年新书推荐】Red Hat Certified Engineer (RHCE) Study Guide