当前位置:网站首页>Regular expression collection
Regular expression collection
2022-07-06 20:47:00 【51CTO】
Regular expressions in common use
Regular expressions in common use !( for example : Matching Chinese 、 matching html)
Regular expressions matching Chinese characters :[u4e00-u9fa5]
Commentary : It's a headache to match Chinese , With this expression, it's easy
Match double byte characters ( Including Chinese characters ):[^x00-xff]
Commentary : Can be used to calculate the length of a string ( A double byte character length meter 2,ASCII Character meter 1)
Regular expressions matching blank lines :ns*r
Commentary : Can be used to delete blank lines
matching HTML Tagged regular expression :<(S*?)[^>]*>.*?|<.*?/>
Commentary : The version circulating on the Internet is too bad , The above one can only match the part , There's nothing we can do about complex nested tags
A regular expression that matches the first and last whitespace characters :^s*|s*$
Commentary : 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
matching Email Regular expression of address :w+([-+.]w+)*@w+([-.]w+)*.w+([-.]w+)*
Commentary : Form validation is very practical
Match URL URL Regular expression of :[a-zA-z]+://[^s]*
Commentary : The function of the version circulated on the Internet is very limited , The above can basically meet the needs
Whether matching account number is legal ( Beginning of letter , allow 5-16 byte , Allow alphanumeric underscores ):^[a-zA-Z][a-zA-Z0-9_]{4,15}$
Commentary : Form validation is very practical
Match domestic phone number :d{3}-d{8}|d{4}-d{7}
Commentary : The matching form is as follows 0511-4405222 or 021-87888822
Matching Tencent QQ Number :[1-9][0-9]{4,}
Commentary : tencent QQ Number from 10000 Start
Match China zip code :[1-9]d{5}(?!d)
Commentary : China Post code is 6 Digit number
Match ID :d{15}|d{18}
Commentary : China's ID card is 15 Bit or 18 position
matching ip Address :d+.d+.d+.d+
Commentary : extract ip Useful for addresses
Match specific numbers :
^[1-9]d*$// Matching positive integer
^-[1-9]d*$// Matching negative integer
^-?[1-9]d*$// Matching integer
^[1-9]d*|0$// Match non negative integers ( Positive integer + 0)
^-[1-9]d*|0$// Match non positive integers ( Negtive integer + 0)
^[1-9]d*.d*|0.d*[1-9]d*$// Match positive floating point
^-([1-9]d*.d*|0.d*[1-9]d*)$// Match negative float
^-?([1-9]d*.d*|0.d*[1-9]d*|0?.0+|0)$// Match floating point
^[1-9]d*.d*|0.d*[1-9]d*|0?.0+|0$// Match non negative floating-point numbers ( Positive floating point + 0)
^(-([1-9]d*.d*|0.d*[1-9]d*))|0?.0+|0$// Match non positive floating-point numbers ( Negative floating point number + 0)
Commentary : Useful when dealing with large amounts of data , Pay attention to correction in specific application
Match specific string :
^[A-Za-z]+$// Match by 26 A string of English letters
^[A-Z]+$// Match by 26 A string of uppercase letters
^[a-z]+$// Match by 26 A string of lowercase letters
^[A-Za-z0-9]+$// Match by numbers and 26 A string of English letters
^w+$// Match by number 、26 A string of English letters or underscores
In the use of RegularExpressionValidator The validation function and validation expression of the validation control are as follows :
You can only enter Numbers :“^[0-9]*$”
Input only n Digit number :“^d{n}$”
You can only enter at least n Digit number :“^d{n,}$”
Input only m-n Digit number :“^d{m,n}$”
Only numbers beginning with zero and non-zero can be entered :“^(0|[1-9][0-9]*)$”
Only positive real numbers with two decimal places can be entered :“^[0-9]+(.[0-9]{2})?$”
Only input has 1-3 Positive real number of decimal places :“^[0-9]+(.[0-9]{1,3})?$”
Only non-zero positive integers can be entered :“^+?[1-9][0-9]*$”
Only non-zero negative integers can be entered :“^-[1-9][0-9]*$”
You can only enter a length of 3 The characters of :“^.{3}$”
Only input from 26 A string of English letters :“^[A-Za-z]+$”
Only input from 26 A string of uppercase letters :“^[A-Z]+$”
Only input from 26 A string of lowercase letters :“^[a-z]+$”
Only numbers and 26 A string of English letters :“^[A-Za-z0-9]+$”
Only numbers can be entered 、26 A string of English letters or underscores :“^w+$”
Verify user password :“^[a-zA-Z]w{5,17}$” The correct format is : Start with a letter , The length is in 6-18 Between ,
Can only contain characters 、 Numbers and underscores .
Verify that it contains ^%&'',;=?$" Equal character :“[^%&'',;=?$x22]+”
Only Chinese characters can be entered :“”
verification Email Address :“^w+[-+.]w+)*@w+([-.]w+)*.w+([-.]w+)*$”
verification InternetURL:“^http://([w-]+.)+[w-]+(/[w-./?%&=]*)?$”
Verify phone number :“^((d{3,4})|d{3,4}-)?d{7,8}$”
The correct format is :“XXXX-XXXXXXX”,“XXXX-XXXXXXXX”,“XXX-XXXXXXX”,
“XXX-XXXXXXXX”,“XXXXXXX”,“XXXXXXXX”.
Authentication ID No (15 Bit or 18 Digit number ):“^d{15}|d{}18$”
Verify one year's 12 Months :“^(0?[1-9]|1[0-2])$” The correct format is :“01”-“09” and “1”“12”
Verify one month's 31 God :“^((0?[1-9])|((1|2)[0-9])|30|31)$”
The correct format is :“01”“09” and “1”“31”.
Regular expressions matching Chinese characters :[u4e00-u9fa5]
Match double byte characters ( Including Chinese characters ):[^x00-xff]
Regular expressions matching empty rows :n[s| ]*r
matching HTML Tagged regular expression :/<(.*)>.*|<(.*)/>/
Regular expression matching the leading and trailing spaces :(^s*)|(s*$)
matching Email Regular expression of address :w+([-+.]w+)*@w+([-.]w+)*.w+([-.]w+)*
Match URL URL Regular expression of :http://([w-]+.)+[w-]+(/[w-./?%&=]*)?
边栏推荐
- 基于STM32单片机设计的红外测温仪(带人脸检测)
- Quel genre de programmation les enfants apprennent - ils?
- Database - how to get familiar with hundreds of tables of the project -navicat these unique skills, have you got it? (exclusive experience)
- ##无yum源安装spug监控
- Recyclerview not call any Adapter method :onCreateViewHolder,onBindViewHolder,
- Pytest (3) - Test naming rules
- Special topic of rotor position estimation of permanent magnet synchronous motor -- Summary of position estimation of fundamental wave model
- 设计你的安全架构OKR
- 2022 Guangdong Provincial Safety Officer C certificate third batch (full-time safety production management personnel) simulation examination and Guangdong Provincial Safety Officer C certificate third
- Rhcsa Road
猜你喜欢
Intel 48 core new Xeon run point exposure: unexpected results against AMD zen3 in 3D cache
基于STM32单片机设计的红外测温仪(带人脸检测)
2022 refrigeration and air conditioning equipment installation and repair examination contents and new version of refrigeration and air conditioning equipment installation and repair examination quest
JMeter server resource indicator monitoring (CPU, memory, etc.)
Digital triangle model acwing 1018 Minimum toll
SQL injection 2
[DIY]如何制作一款個性的收音機
Number of schemes from the upper left corner to the lower right corner of the chessboard (2)
PHP online examination system version 4.0 source code computer + mobile terminal
[DSP] [Part 2] understand c6678 and create project
随机推荐
2110 summary of knowledge points and common problems in redis class
APS taps home appliance industry into new growth points
自定义限流注解
Activiti global process monitors activitieventlistener to monitor different types of events, which is very convenient without configuring task monitoring in acitivit
Zoom with unity mouse wheel: zoom the camera closer or farther
[200 opencv routines] 220 Mosaic the image
User defined current limiting annotation
Laravel笔记-自定义登录中新增登录5次失败锁账户功能(提高系统安全性)
华为设备命令
[diy] how to make a personalized radio
Pycharm remote execution
Extraction rules and test objectives of performance test points
How to turn a multi digit number into a digital list
Boder radius has four values, and boder radius exceeds four values
Value of APS application in food industry
知识图谱构建流程步骤详解
Detailed explanation of knowledge map construction process steps
基于STM32单片机设计的红外测温仪(带人脸检测)
解剖生理学复习题·VIII血液系统
[weekly pit] calculate the sum of primes within 100 + [answer] output triangle