当前位置:网站首页>Quick reference manual for the strongest collation of common regular expressions (glory Collection Edition)
Quick reference manual for the strongest collation of common regular expressions (glory Collection Edition)
2022-07-24 04:43:00 【Dragon back ride Shi】

Catalog
One 、 Check the expression of a number
Two 、 Expression for check character
3、 ... and 、 Expression of special requirements
One 、 Check the expression of a number
Numbers
^[0-9]*$n Digit number
^\d{n}$At least n Digit number
^\d{n,}$m-n Digit number
^\d{m,n}$Zero and non-zero digits
^(0|[1-9][0-9]*)$A number with a maximum of two decimal places beginning with a nonzero
^([1-9][0-9]*)+(.[0-9]{1,2})?$belt 1-2 Positive or negative number of decimal places
^(\-)?\d+(\.\d{1,2})?$Positive numbers 、 negative 、 And decimal fraction
^(\-|\+)?\d+(\.\d+)?$A positive real number with two decimal places
^[0-9]+(.[0-9]{2})?$Yes 1~3 Positive real number of decimal places
^[0-9]+(.[0-9]{1,3})?$Nonzero positive integer
^[1-9]\d*$ or ^([1-9][0-9]*){1,3}$ or ^\+?[1-9][0-9]*$Nonzero negative integer
^\-[1-9][]0-9"*$ or ^-[1-9]\d*$Non-negative integer
^\d+$ or ^[1-9]\d*|0$Non positive integer
^-[1-9]\d*|0$ or ^((-\d+)|(0+))$Nonnegative floating point number
^\d+(\.\d+)?$ or ^[1-9]\d*\.\d*|0\.\d*[1-9]\d*|0?\.0+|0$Non positive floating point number
^((-\d+(\.\d+)?)|(0+(\.0+)?))$ or ^(-([1-9]\d*\.\d*|0\.\d*[1-9]\d*))|0?\.0+|0$Positive floating point
^[1-9]\d*\.\d*|0\.\d*[1-9]\d*$ or ^(([0-9]+\.[0-9]*[1-9][0-9]*)|([0-9]*[1-9][0-9]*\.[0-9]+)|([0-9]*[1-9][0-9]*))$Negative floating point number
^-([1-9]\d*\.\d*|0\.\d*[1-9]\d*)$ or ^(-(([0-9]+\.[0-9]*[1-9][0-9]*)|([0-9]*[1-9][0-9]*\.[0-9]+)|([0-9]*[1-9][0-9]*)))$Floating point numbers
^(-?\d+)(\.\d+)?$ or ^-?([1-9]\d*\.\d*|0\.\d*[1-9]\d*|0?\.0+|0)$Two 、 Expression for check character
Chinese characters
^[\u4e00-\u9fa5]{0,}$English and numbers
^[A-Za-z0-9]+$ or ^[A-Za-z0-9]{4,40}$The length is 3-20 All characters of
^.{3,20}$from 26 A string of English letters
^[A-Za-z]+$from 26 A string of uppercase letters
^[A-Z]+$from 26 A string of lowercase letters
^[a-z]+$By numbers and 26 A string of English letters
^[A-Za-z0-9]+$By digital 、26 A string of English letters or underscores
^\w+$ or ^\w{3,20}chinese 、 english 、 Numbers include underscores
^[\u4E00-\u9FA5A-Za-z0-9_]+$chinese 、 english 、 Number but excluding symbols such as underscores
^[\u4E00-\u9FA5A-Za-z0-9]+$ or ^[\u4E00-\u9FA5A-Za-z0-9]{2,20}$Can be entered with
^%&',;=?$\"Equal character[^%&',;=?$\x22]+Disable input containing ~ The characters of
[^~\x22]+Other :
.*Matching elimination\nAny character other than ./[\u4E00-\u9FA5]/Chinese characters/[\uFF00-\uFFFF]/Full angle symbol/[\u0000-\u00FF]/Half angle symbol
3、 ... and 、 Expression of special requirements
Email Address
^\w+([-+.]\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*$domain name
[a-zA-Z0-9][-a-zA-Z0-9]{0,62}(/.[a-zA-Z0-9][-a-zA-Z0-9]{0,62})+/.?InternetURL
[a-zA-z]+://[^\s]* or ^http://([\w-]+\.)+[\w-]+(/[\w-./?%&=]*)?$Phone number
^(13[0-9]|14[5|7]|15[0|1|2|3|5|6|7|8|9]|18[0|1|2|3|5|6|7|8|9])\d{8}$Phone number
("XXX-XXXXXXX"、"XXXX-XXXXXXXX"、"XXX-XXXXXXX"、"XXX-XXXXXXXX"、"XXXXXXX" and "XXXXXXXX): ^(\(\d{3,4}-)|\d{3.4}-)?\d{7,8}$Domestic phone number
(0511-4405222、021-87888822):\d{3}-\d{8}|\d{4}-\d{7}ID number (15 position 、18 Digit number )
^\d{15}|\d{18}$Short ID number ( Numbers 、 Letter x ending )
^([0-9]){7,18}(x|X)?$ or ^\d{8,18}|[0-9x]{8,18}|[0-9X]{8,18}?$Is the account number legal ( Beginning of letter , allow 5-16 byte , Allow alphanumeric underscores )
^[a-zA-Z][a-zA-Z0-9_]{4,15}$password ( Start with a letter , The length is in 6~18 Between , Can only contain letters 、 Numbers and underscores )
^[a-zA-Z]\w{5,17}$Strong password ( 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}$Date format
^\d{4}-\d{1,2}-\d{1,2}One year 12 Months (01~09 and 1~12)
^(0?[1-9]|1[0-2])$A month 31 God (01~09 and 1~31)
^((0?[1-9])|((1|2)[0-9])|30|31)$
3.1. Input format of money
1. There are four forms of money we can accept :"10000.00" and "10,000.00", And no " branch " Of "10000" and "10,000"
^[1-9][0-9]*$2. This means that either of them can't 0 Number at the beginning , however , It also means a character "0" Not through , So we take the following form
^(0|[1-9][0-9]*)$3. One 0 Or one doesn't 0 Number at the beginning . We can also allow a minus sign at the beginning
^(0|-?[1-9][0-9]*)$4. This means a 0 Or a start that may be negative is not 0 The number of . Let users 0 The beginning is good. . Remove the minus sign as well , Because money can't be negative . What we're going to add here is the possible decimal part
^[0-9]+(.[0-9]+)?$5. It must be noted that , There should be at least one after the decimal point 1 digit , therefore "10." No way , however "10" and "10.2" Yes. :
^[0-9]+(.[0-9]{2})?$6. In this way, we stipulate that there must be two decimal places after the decimal point , If you think it's too harsh , It can be like this
^[0-9]+(.[0-9]{1,2})?$7. This allows the user to write only one decimal place . Now it's time to think about commas in numbers , We can do this
^[0-9]{1,3}(,[0-9]{3})*(.[0-9]{1,2})?$8.1 To 3 A digital , Follow any one comma +3 A digital , Comma as optional , Not necessarily
^([0-9]+|[0-9]{1,3}(,[0-9]{3})*)(.[0-9]{1,2})?$remarks : This is the end result , Don't forget
+It can be used*Instead, if you think empty strings are acceptable ( strange , Why? ?) Last , Don't forget to remove the backslash when using functions , Common mistakes are here
xml file
^([a-zA-Z]+-?)+[a-zA-Z0-9]+\\.[x|X][m|M][l|L]$Regular expression of Chinese characters
[\u4e00-\u9fa5]Double byte character
[^\x00-\xff] ( Including Chinese characters , Can be used to calculate the length of a string ( A double byte character length meter 2,ASCII Character meter 1))Regular expression for blank lines
\n\s*\r ( Can be used to delete blank lines )HTML Tagged regular expression
<(\S*?)[^>]*>.*?</\1>|<.*? /> ( The version circulating on the Internet is too bad , This one is only part of it , There's nothing we can do about complex nested tags )Regular expression of first and last whitespace characters
^\s*|\s*$ or (^\s*)|(\s*$) ( Can be used to delete blank characters at the beginning and end of a line ( Including Spaces 、 tabs 、 Page breaks and so on ), Very useful expressions )tencent QQ Number
[1-9][0-9]{4,} ( tencent QQ Number from 10000 Start )China Post Code
[1-9]\d{5}(?!\d) ( China Post code is 6 Digit number )IP Address
\d+\.\d+\.\d+\.\d+ ( extract IP Useful for addresses )IP Address
((?:(?:25[0-5]|2[0-4]\\d|[01]?\\d?\\d)\\.){3}(?:25[0-5]|2[0-4]\\d|[01]?\\d?\\d))IP-v4 Address
\\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 ( extract IP Useful for addresses )check IP-v6 Address
(([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])) ( It's too complicated , The mentality is about to collapse ...)Subnet mask
((?:(?:25[0-5]|2[0-4]\\d|[01]?\\d?\\d)\\.){3}(?:25[0-5]|2[0-4]\\d|[01]?\\d?\\d))Verification date
^(?:(?!0000)[0-9]{4}-(?:(?:0[1-9]|1[0-2])-(?:0[1-9]|1[0-9]|2[0-8])|(?:0[13-9]|1[0-2])-(?:29|30)|(?:0[13578]|1[02])-31)|(?:[0-9]{2}(?:0[48]|[2468][048]|[13579][26])|(?:0[48]|[2468][048]|[13579][26])00)-02-29)$(“yyyy-mm-dd“ Format date verification , A flat leap year has been considered .)Extract comments
<!--(.*?)-->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}([^\\"\\'\\ >]*)Extract web page color code
^#([A-Fa-f0-9]{6}|[A-Fa-f0-9]{3})$File extension validation
^([a-zA-Z]\\:|\\\\)\\\\([^\\\\]+\\\\)*[^\\/:*?"<>|]+\\.txt(l)?$Judge IE edition
^.*MSIE [5-8](?:\\.[0-9]+)?(?!.*Trident\\/[5-9]\\.0).*$
Schedule :( I really can't knock , Lazy on the picture )










Only when you start , You will reach your ideal and destination , Only when you work hard ,
You will achieve brilliant success , Only when you sow , You will gain something . Only pursue ,
To taste the taste of success , Sticking to yesterday is called foothold , Sticking to today is called enterprising , Sticking to tomorrow is called success . Welcome all friends to praise + Collection !!!
边栏推荐
- 黑色的的一站式运维管家 10条记录RO
- 仿今日头条实时新闻微信小程序项目源码
- C语言经典习题之编写一个程序,找出1000以内所有的完数。
- What is the proper resolution of the computer monitor? Introduction to the best resolution of monitors of various sizes and the selection of different wallpapers
- Esp32 tutorial (I): vscode+platform and vscade+esp-idf
- C语言经典习题之猴子吃桃问题
- Excel cell formula - realize Ackerman function calculation
- The software cannot be uninstalled. Please wait for the current program to complete the uninstallation or change the solution
- Forward proxy, reverse proxy and XFF
- To -.---
猜你喜欢

Introduction and use of pycharm debugging function

Several common sorts

Sort - quicksort

greatest common divisor

uniapp学习

HMS core discovery Episode 16 live broadcast preview | play AI's new "sound" state with tiger pier

后 SQL 时代降临:EdgeDB 2.0 发布会预告

Esp32:arduino tutorial summary

Privacy protection federal learning framework supporting most irregular users

Application scenarios and schemes of common mechanical equipment safety virtual simulation system
随机推荐
C语言经典习题之评委打分去掉最高最低求平均分
Smart people's game improvement: Chapter 3 Lesson 3 example: the secret of prime
"Paper reproduction" bidaf code implementation process (3) model establishment
Array force buckle (continuously updated)
Black one-stop operation and maintenance housekeeper 10 records ro
A hospital call system based on C language
Write a search box with search tips
The problem of monkeys eating peaches in classic exercises of C language
Esp32 tutorial (I): vscode+platform and vscade+esp-idf
P一个配置文件期间将SDA松集成。支但事实上
Xiaomi finance was officially launched today (May 11) with a free 10000 yuan experience fee attached to the official address
Little black leetcode journey: 100 same trees
C语言经典习题之猴子吃桃问题
Qt5.14_MinGW/MSVC下实现VS2019面板自由拖拽组合功能
.gz的业务交互和对外服篇中我们通合多个模型
00cm non, make sure to go online with the business party once in advance, and make everything better
Middle aged crisis, workplace dad who dare not leave, how to face life's hesitation
激活函数和最常用的10个激活函数
Design of two power dividers and directional couplers for basic experiment of microwave technology
How to download vscode using domestic image seconds