当前位置:网站首页>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
边栏推荐
- Project, how to package
- Machine learning II: logistic regression classification based on Iris data set
- Cancel remote dependency and use local dependency
- [2021 book recommendation] learn winui 3.0
- PyTorch 12. hook的用法
- Summary of image classification white box anti attack technology
- Miscellaneous learning
- 给女朋友写个微信双开小工具
- Exploration of SendMessage principle of advanced handler
- Pytorch trains the basic process of a network in five steps
猜你喜欢
[Point Cloud Series] SG - Gan: Adversarial Self - attachment GCN for Point Cloud Topological parts Generation
机器学习 三: 基于逻辑回归的分类预测
c语言编写一个猜数字游戏编写
给女朋友写个微信双开小工具
[2021 book recommendation] red hat rhcsa 8 cert Guide: ex200
【2021年新书推荐】Professional Azure SQL Managed Database Administration
【点云系列】Pointfilter: Point Cloud Filtering via Encoder-Decoder Modeling
第3章 Pytorch神经网络工具箱
【2021年新书推荐】Enterprise Application Development with C# 9 and .NET 5
ArcGIS License Server Administrator 无法启动解决方法
随机推荐
.net加载字体时遇到 Failed to decode downloaded font:
【2021年新书推荐】Red Hat RHCSA 8 Cert Guide: EX200
【點雲系列】SG-GAN: Adversarial Self-Attention GCN for Point Cloud Topological Parts Generation
机器学习——PCA与LDA
【动态规划】最长递增子序列
GEE配置本地开发环境
Raspberry Pie: two color LED lamp experiment
【Tensorflow】共享机制
【点云系列】Unsupervised Multi-Task Feature Learning on Point Clouds
[2021 book recommendation] red hat rhcsa 8 cert Guide: ex200
Data class of kotlin journey
[point cloud series] sg-gan: advantageous self attention GCN for point cloud topological parts generation
【2021年新书推荐】Artificial Intelligence for IoT Cookbook
Migrating your native/mobile application to Unified Plan/WebRTC 1.0 API
xcode 编译速度慢的解决办法
MySQL notes 4_ Primary key auto_increment
Gephi tutorial [1] installation
[Point Cloud Series] SG - Gan: Adversarial Self - attachment GCN for Point Cloud Topological parts Generation
What did you do during the internship
[2021 book recommendation] kubernetes in production best practices