当前位置:网站首页>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 ~
边栏推荐
- 【C语言笔记分享】——动态内存管理malloc、free、calloc、realloc、柔性数组
- 微信小程序 TODO案例
- 如何在树莓派上搭建运行 WordPress
- Centos7 installs Damon stand-alone database
- Binlog and iptables prevent nmap scanning, xtrabackup full + incremental backup, and the relationship between redlog and binlog
- 看完这篇文章,才发现我的测试用例写的就是垃圾
- Moving the mouse into select options will trigger the mouseleave event processing scheme
- SQL Server 启停作业脚本
- 天然气潮流计算matlab程序
- 栈与队列——225. 用队列实现栈
猜你喜欢

Notes on the use of IEEE transaction journal template

After reading this article, I found that my test cases were written in garbage

Nmap security testing tool tutorial
![[untitled] rhcsa first operation](/img/ba/6b9c11edbc18ffb52f6046360b5b10.png)
[untitled] rhcsa first operation

北京一卡通以35288.8529万元挂牌出让68.45%股权,溢价率为84%
![[oauth2] II. Authorization method of oauth2](/img/9f/0098394a341a9dfb0cf8a862f46049.png)
[oauth2] II. Authorization method of oauth2

电赛设计报告模板及历年资源

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

IEEE Transaction期刊模板使用注意事项

5年接触近百位老板,身为猎头的我,发现升职的秘密不过4个字
随机推荐
[oauth2] IV. oauth2authorizationrequestredirectfilter
MySQL community download address
C language -- program environment and preprocessing
SQL Server 启停作业脚本
Rasa 3.x 学习系列-Rasa [3.2.4] - 2022-07-21 新版本发布
Solve the problem that uni starter can log in to wechat with local functions, but fails to log in with cloud functions
Rasa 3.x 学习系列-Rasa [3.2.3] - 2022-07-18 新版本发布
Bibliometrix: dig out the one worth reading from thousands of papers!
The latest and complete Flink series tutorials in 2021_ Preliminary exploration of Flink principle and flow batch integration API (II. V) V2
R language test sample proportion: use the prop.test function to perform a single sample proportion test to calculate the confidence interval of the p value of the successful sample proportion in the
[oauth2] II. Authorization method of oauth2
清除字符串中所有空格
Detailed analysis of common command modules of ansible service
Rasa 3.x 学习系列-Rasa FallbackClassifier源码学习笔记
5年接触近百位老板,身为猎头的我,发现升职的秘密不过4个字
2022.7.22 simulation match
微信小程序 TODO案例
自动化运维之Ansible安装部署
String - 459. Repeated substrings
JS judge whether it is an integer