当前位置:网站首页>Can't remember regular expressions? Here I have sorted out 99 common rules
Can't remember regular expressions? Here I have sorted out 99 common rules
2022-07-24 14:13:00 【_ Ah Biao】
Number class
cell-phone number ( With 1 start ):/^(?:(?:\+|00)86)?1\d{10}$/
cell-phone number ( With 13 to 19 start ):/^(?:(?:\+|00)86)?1[3-9]\d{9}$/
cell-phone number ( Start with the mobile phone number segment published by the Ministry of industry and information technology ):/^(?:(?:\+|00)86)?1(?:(?:3[\d])|(?:4[5-79])|(?:5[0-35-9])|(?:6[5-7])|(?:7[0-8])|(?:8[\d])|(?:9[189]))\d{8}$/
Domestic fixed line number :/\d{3}-\d{8}|\d{4}-\d{7}/
Mail box number :/^\w+([-+.]\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*$/
Postal Code :/[1-9]\d{5}(?!\d)/
ID number :/^[1-9]\d{5}(?:18|19|20)\d{2}(?:0[1-9]|10|11|12)(?:0[1-9]|[1-2]\d|30|31)\d{3}[\dXx]$/
Bank card number ( Male 、 Private account ):/^[1-9]\d{9,29}$/
license plate number :/^[ Beijing, Tianjin, Shanghai, Chongqing, Hebei, Henan, Yunnan, Liaoning, Heilongjiang, Hunan, Anhui, Shandong, new Jiangsu, Zhejiang, Jiangxi, Hubei, Guangxi, Gansu, Shanxi, Inner Mongolia, Shaanxi, Jilin, Fujian, Guizhou, Guangdong, Qinghai Tibet, Sichuan, Ningxia and Hainan ][A-HJ-NP-Z][A-HJ-NP-Z0-9]{4,5}[A-HJ-NP-Z0-9 Hang the school police in Hong Kong and Macao ]$/
QQ Number :/^[1-9][0-9]{4,10}$/
WeChat ID :/^[a-zA-Z][-_a-zA-Z0-9]{5,19}$/
Version number ( x.y.z ):/^\d+(?:\.\d+){2}$/
Legal account 1( Beginning of letter ,5-16 position , Allow alphanumeric underscores ):/^[a-zA-Z][a-zA-Z0-9_]{4,15}$/
Legal account 2(4-16 position , Allow letters , Numbers , Underline , minus sign ):/^[a-zA-Z0-9_-]{4,16}$/
Strong password 1( Must contain a combination of upper and lower case letters and numbers , Special characters cannot be used , The length is in 8-10 Between ):/^(?=.*\d)(?=.*[a-z])(?=.*[A-Z]).{8,10}$/
Strong password 2( Must contain letters 、 Numbers 、 Special characters :**@#$%^& `~()-+=* ):
/^(?![a-zA-Z]+$)(?![A-Z0-9]+$)(?![A-Z\[email protected]#$%^&* ~()-+=]+$)(?![a-z0-9]+$)(?![a-z\\[email protected]#$%^& *~()-+=]+$)(?![0-9\[email protected]#$%^&* ~()-+=]+$)[a-zA-Z0-9\\[email protected]#$%^&*~()-+=]/
website :/^(((ht|f)tps?):\/\/)?(^[email protected]#$%^&*?.\s-?\.)+[a-z]{2,6}\/?/
The website has a port number :/^((ht|f)tps?:\/\/)?[\w-]+(\.[\w-]+)+:\d{1,5}\/?$/
ip-v4:/\\b(?:(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\\.){3}(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\\b/
ip-v6:/(([0-9a-fA-F]{1,4}:){7,7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))/Digital class
Only numbers :/^[0-9]*$/ or /^\d{1,}$/
Integers :/^-?[0-9]\d*$/
Positive integer :/^\+?[1-9]\d*$/
Non positive integer :/^-[1-9]\d*|0$/
Negtive integer :/^-[1-9]\d*$/
Non-negative integer :/^\d+$/
Floating point numbers :/^(-?\d+)(\.\d+)?$/
Positive floating point :/^[1-9]\d*\.\d*|0\.\d*[1-9]\d*$/
Negative floating point number :/^-([1-9]\d*\.\d*|0\.\d*[1-9]\d*)/
decimal :/^-?\d+\.\d+$/
Positive numbers / negative / decimal :/^(\-|\+)?\d+(\.\d+)?$/
Positive real numbers are kept after the decimal point 2 position :/^[0-9]+(.[0-9]{2})?$/
Positive real numbers are kept after the decimal point 1 To 3 position :/^[0-9]+(.[0-9]{1,3})?$/
n Digit number :/^\d{n}$/
At least n Digit number :/^\d{n,}$/
m to n Digit number :/^\d{m,n}$/
Numbers and letters contain at least one :/^[A-Za-z0-9]+$/
Must contain numbers and letters :/^(?=.*[a-zA-Z])(?=.*\d).+$/
md5 value :/^([a-f\d]{32}|[A-F\d]{32})$/
base64 value :/^\s*data:(?:[a-z]+\/[a-z0-9-+.]+(?:;[a-z-]+=[a-z0-9-]+)?)?(?:;base64)?,([a-z0-9!$&',()*+;=\-._~:@/?%\s]*?)\s*$/iCharacter class
to n A character :/^.{3,20}$/
Alphabetic characters :/^[A-Za-z]+$/
Capitalized English alphabetic characters :/^[A-Z]+$/
Lowercase English alphabetic characters :/^[a-z]+$/
Chinese characters :/^[\u4e00-\u9fa5]{0,}$/
Full angle symbol :/[\uFF00-\uFFFF]/
Half angle symbol :/[\u0000-\u00FF]/
Chinese characters 、 english 、 Numbers 、 Underline at least one :/^[\u4E00-\u9FA5A-Za-z0-9_]+$/
Does not contain characters “~” :/[^~\x22]+/
Characters repeat continuously :/(.)\1+/ Time class
24 Hour time (HH:mm:ss):/^(?:[01]\d|2[0-3]):[0-5]\d:[0-5]\d$/
12 Hour time (hh:mm:ss):/^(?:1[0-2]|0?[1-9]):[0-5]\d:[0-5]\d$/
24 Hour time (HHmmss):/([0-1]?[0-9]|2[0-3])([0-5][0-9])([0-5][0-9])$/
date 1(yyyy-MM-dd, Such as 2222-01-01, The year must be 4 position ):/^\d{4}-\d{1,2}-\d{1,2}/
date 2( Such as 333-01-01, The year can be less than 4 position ):/^\d{1,4}(-)(1[0-2]|0?[1-9])\1(0?[1-9]|[1-2]\d|30|31)$/
date 3(yyyyMMdd, Such as 20220202):/^((([0-9]{3}[1-9]|[0-9]{2}[1-9][0-9]{1}|[0-9]{1}[1-9][0-9]{2}|[1-9][0-9]{3})(((0[13578]|1[02])(0[1-9]|[12][0-9]|3[01]))|((0[469]|11)(0[1-9]|[12][0-9]|30))|(02(0[1-9]|[1][0-9]|2[0-8]))))|((([0-9]{2})(0[48]|[2468][048]|[13579][26])|((0[48]|[2468][048]|[3579][26])00))0229))$/
date + Time 1(YYYYMMDD HH:mm:ss):/^\d{4}([/:-\S])(1[0-2]|0?[1-9])\1(0?[1-9]|[1-2]\d|30|31) (?:[01]\d|2[0-3]):[0-5]\d:[0-5]\d$/
date + Time 2:/^[1-9]\d{3}-(0[1-9]|1[0-2])-(0[1-9]|[1-2][0-9]|3[0-1])\s+(20|21|22|23|[0-1]\d):[0-5]\d:[0-5]\d$/
A year 12 Months ((01~09 or 1~12)):/^(0?[1-9]|1[0-2])$/
A month 31 God (01~09 or 1~31):/^((0?[1-9])|((1|2)[0-9])|30|31)$/
Yes 31 Day's month :/^(0?[13578]|1[02])$/
Yes 30 Days and months :/(0[469]|11)-(0[1-9]|[12][0-9]|30)/
2 month 28 God ("02-28"):/^02-(0[1-9]|[1][0-9]|2[0-8])$/
Leap year :/^(((19|20)([13579][26]|[2468][048]|0[48]))|(2000))$/
Leap year 2 month ( such as 2008-02-01):/^(((19|20)([13579][26]|[2468][048]|0[48]))|(2000))-0?2-(0?[1-9]|[12]\d)$/
date ( Including leap years 、 Judgment of big and small months ):/((((19|20)\d{2})-(0?(1|[3-9])|1[012])-(0?[1-9]|[12]\d|30))|(((19|20)\d{2})-(0?[13578]|1[02])-31)|(((19|20)\d{2})-0?2-(0?[1-9]|1\d|2[0-8]))|((((19|20)([13579][26]|[2468][048]|0[48]))|(2000))-0?2-29))$/
Year range - year ( such as 19 - 20 year ):/^((19|20)\d{2})$/
Year range - years ( such as 1999-01):/^((((19|20)\d{2})-(0?[13-9]|1[012]))|(((19|20)\d{2})-(0?[13578]|1[02]))|(((19|20)\d{2})-0?2)|((((19|20)([13579][26]|[2468][048]|0[48]))|(2000))-0?2))$/
Year range - Specific date ( such as 1999-01-01):/^((((19|20)\d{2})-(0?[13-9]|1[012])-(0?[1-9]|[12]\d|30))|(((19|20)\d{2})-(0?[13578]|1[02])-31)|(((19|20)\d{2})-0?2-(0?[1-9]|1\d|2[0-8]))|((((19|20)([13579][26]|[2468][048]|0[48]))|(2000))-0?2-29))$/.test('2021-02-21')$/
Year range - Specific date ( The interval symbol can be - / Or empty ):/^(?:(?:1[6-9]|[2-9][0-9])[0-9]{2}([-/.]?)(?:(?:0?[1-9]|1[0-2])\1(?:0?[1-9]|1[0-9]|2[0-8])|(?:0?[13-9]|1[0-2])\1(?:29|30)|(?:0?[13578]|1[02])\1(?:31))|(?:(?:1[6-9]|[2-9][0-9])(?:0[48]|[2468][048]|[13579][26])|(?:16|[2468][048]|[3579][26])00)([-/.]?)0?2\2(?:29))$/Procedure class
16 Binary color :/^#?([a-fA-F0-9]{6}|[a-fA-F0-9]{3})$/
Extract web page color code :/^#([A-Fa-f0-9]{6}|[A-Fa-f0-9]{3})$/
Video link address :/^https?:\/\/(.+\/)+.+(\.(swf|avi|flv|mpg|rm|mov|wav|asf|3gp|mkv|rmvb|mp4))$/i
Picture link address :/^https?:\/\/(.+\/)+.+(\.(gif|png|jpg|jpeg|webp|svg|psd|bmp|tif))$/i
mac Address :/^((([a-f0-9]{2}:){5})|(([a-f0-9]{2}-){5}))[a-f0-9]{2}$/i
Subnet mask :/^((?:(?:25[0-5]|2[0-4]\\d|[01]?\\d?\\d)\\.){3}(?:25[0-5]|2[0-4]\\d|[01]?\\d?\\d))$/
File extension validation :/^([a-zA-Z]\\:|\\\\)\\\\([^\\\\]+\\\\)*[^\\/:*?"<>|]+\\.txt(l)?$/
java Package name (x.x.x):/^([a-zA-Z_]\w*)+([.][a-zA-Z_]\w*)+$/
xml file :/^([a-zA-Z]+-?)+[a-zA-Z0-9]+\\.[x|X][m|M][l|L]$/
html notes :/<!--[\s\S]*?-->/g
html label 1:/<(\w+)[^>]*>(.*?<\/\1>)?/
html label 2:/<(\S*?)[^>]*>.*?</\1>|<.*? />/
First and last white space characters :/^\s*|\s*$/
lookup CSS attribute :/^\\s*[a-zA-Z\\-]+\\s*[:]{1}\\s[a-zA-Z0-9\\s.#]+[;]{1}/
Extract page hyperlinks :/(<a\\s*(?!.*\\brel=)[^>]*)(href="https?:\\/\\/)((?!(?:(?:www\\.)?'.implode('|(?:www\\.)?', $follow_list).'))[^" rel="external nofollow" ]+)"((?!.*\\brel=)[^>]*)(?:[^>]*)>/
Take pictures of web pages :/\\< *[img][^\\\\>]*[src] *= *[\\"\\']{0,1}([^\\"\\'\\ >]*)/
Thunderbolt link :/^thunder:\/\/[a-zA-Z0-9]+=$/
ed2k link :/^ed2k:\/\/|file|.+|\/$/
linux" file " route :/^\/(\w+\/)+\w+\.\w+$/
window Next " file " route :/^[a-zA-Z]:\\(?:\w+\\)*\w+\.\w+$/lifestyle
amount of money ( loose , It can be negative 、 The first can be 0, It supports thousand digit separation ):/^-?\d+(,\d{3})*(\.\d{1,2})?$/
amount of money ( Greater than 0 , Two decimal places ):/(^[1-9]{1}[0-9]*$)|(^[0-9]*\.[0-9]{2}$)/
amount of money ( Strictly , Not negative 、 Up to two digits after the decimal point , The first is not 0):/(^[1-9]([0-9]+)?(\.[0-9]{1,2})?$)|(^(0){1}$)|(^[0-9]\.[0-9]([0-9])?$)/
passport :/(^[EeKkGgDdSsPpHh]\d{8}$)|(^(([Ee][a-fA-F])|([DdSsPp][Ee])|([Kk][Jj])|([Mm][Aa])|(1[45]))\d{7}$)/
Hong Kong Identity Card :/^[a-zA-Z]\d{6}\([\dA]\)$/
Macao identity card :/^[1|5|7]\d{6}\(\d\)$/
Wan Wan ID card :/^[a-zA-Z][0-9]{9}$/
Stock code :/^(s[hz]|S[HZ])(000[\d]{3}|002[\d]{3}|300[\d]{3}|600[\d]{3}|60[\d]{4})$/
Not included abc 's words :/\b((?!abc)\w)+\b/Summary :
This article has sorted out a wave of regularities , Many of them also learn while watching
If there is any supplementary , Feel free to leave a comment , Or there are mistakes , Welcome to come up with , Revise now . I hope I can learn from your regularity 、 It helps to use ~
边栏推荐
- Mmdrawercontroller gets the current VC for push and pop
- Remove the treasure box app with the green logo that cannot be deleted from iPhone
- Multithreaded common classes
- The solution to the error of [installation detects that the primary IP address of the system is the address assigned by DHCP] when installing Oracle10g under win7
- Csp2021 T3 palindrome
- Introduction to Xiaoxiong school
- Flink advanced features and new features (VIII)
- Unity行人随机行走不碰撞
- Error importing header file to PCH
- 字符串——459. 重复的子字符串
猜你喜欢

天然气潮流计算matlab程序

达梦实时主备集群搭建

After reading this article, I found that my test cases were written in garbage
![[C language note sharing] - dynamic memory management malloc, free, calloc, realloc, flexible array](/img/3f/35c9ff3be5c0ef781ffcb537287a20.png)
[C language note sharing] - dynamic memory management malloc, free, calloc, realloc, flexible array

Bibliometrix: dig out the one worth reading from thousands of papers!

OWASP ZAP安全测试工具使用教程(高级)

Centos7 installs Damon stand-alone database

小熊派 课程导读

【C语言笔记分享】——动态内存管理malloc、free、calloc、realloc、柔性数组

Uni app background audio will not be played after the screen is turned off or returned to the desktop
随机推荐
sql server语法—创建数据库
Cocoapod installation problems
CAS atomic type
C# 多线程锁整理记录
自动化运维之Ansible安装部署
Concurrent programming ----------- set
栈与队列——20. 有效的括号
Ansible服务常用命令模块详细解析
OC sets the image fillet, and the image is not deformed
解决 uni-starter 使用本地函数可以登录微信 但是使用云函数登录失败
String - Sword finger offer 58 - ii Rotate string left
Build ZABBIX monitoring service in LNMP architecture
微信小程序 TODO案例
C# unsafe 非托管对象指针转换
R language uses the sum function of epidisplay package to calculate the descriptive statistical summary information of the specified variables in dataframe under different grouping variables, visualiz
Mmdrawercontroller first loading sidebar height problem
[untitled]
R language uses the statstack function of epidisplay package to view the statistics (mean, median, etc.) of continuous variables and the corresponding hypothesis test in a hierarchical manner based on
Unity pedestrians walk randomly without collision
【机器学习】之 主成分分析PCA