Summary of Common Regular Expressions

Author:Smart Tool Kit Release time:2022-02-25 20:56:00 Number of words:2852 Reading:14511Times
Functions Regular expressions
Integers (including 0) ^-? [0-9]\d*$
Positive integers (including 0) ^[0-9]\\d*$
Negative integers (excluding 0) ^-[0-9]\\d*$
Numbers (including 0) ^([+-]?) \\\d*\\\\...? \\\d+$
Positive numbers (including 0) ^[0-9]\\d*|0$
Negative numbers (excluding 0) ^-[1-9]\\\d*|0$
Floating point numbers or integers ^\\\d+(\\\. \\\d+)? $
Floating point number ^([+-]?) \\\d*\\\\. \\d+$
Positive floating-point numbers ^[1-9]\\\d*. \\\d*|0.\\d*[1-9]\\d*|0?.0+|0$
Negative Floating Point Numbers ^(-([1-9]\\\d*. \\d*|0.\d*[1-9]\d*))|0?.0+|0$
Non-negative floating-point numbers (positive floating-point numbers + 0, with one decimal place) ^(([0-9]+\. [0-9]{1})|([0-9]*[1-9][0-9]*\. [0-9]{1})|([0-9]*[0-9]{1})$)
E-mail ^[a-zA-Z0-9.! #$%&'*+\/=? ^_`{|}~-]+@[a-zA-Z0-9](? :[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])? (? :\. [a-zA-Z0-9](? :[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)*$
Colors ^[a-fA-F0-9]{6}$
url ^http[s]? :\\\/\\\/([\\\\w-]+\\\...) +[\\\w-]+([\\\w-. /? %&=]*)? $
Chinese only ^[\\\u4E00-\\u9FA5\\uF900-\uFA2D]+$
ACSII characters only ^[\\x00-\\xFF]+$
Zip code ^\\\d{6}$
Cell phone number ^(11|12|13|14|15|16|17|18|19)[0-9]{9}$
Cell phone number and landline number (^1[1|2|3|4|5|6|7|8|9][0-9]\d{8}$)|(^(0[0-9]{2,3}\-)? ([2-9][0-9]{6,7})+(\-[0-9]{1,4})? $)
Non-empty ^\\\S+$
Alphabet ^[A-Za-z]+$
Upper case only ^[A-Z]+$
Lowercase letters only ^[a-z]+$
Password (must contain numbers, letters, special characters and be 6-12 digits long) ^(?! \D+$)(?! [a-zA-Z0-9]+$)(?! [^a-zA-Z0-9]+$)\S{6,12}$
Password (must contain letters and numbers and be 8-12 digits long) ^(?! \D+$)(?! [^a-z]+$)\S{8,12}$
Password (must contain numbers, uppercase letters, lowercase letters, special characters and be 6-12 characters long) ^(?! \D+$)(?! [a-z]+$)(?! [^A-Z]+$)\S{6,12}$
Time ^([0-1]? [0-9]|2[0-3]):([0-5][0-9]):([0-5][0-9])$
Date + Time (((^((1[8-9]\d{2})|([2-9]\d{3})))([-\/\. _])(10|12|0?[13578])([-\/\. _])(3[01]|[12][0-9]|0?[1-9]))|(^((1[8-9]\d{2})|([2-9]\d{3}))(-\/\. _])(11|0?[469])([-\/\. _])(30|[12][0-9]|0?[1-9]))|(^((1[8-9]\d{2})|([2-9]\d{3}))([-\/\. _])(0?2)([-\/\. _])(2[0-8]|1[0-9]|0?[1-9]))|(^([2468][048]00)([-\\/\. _])(0?2)([-\/\. _])(29))|(^([3579][26]00)([-\/\. _])(0?2) ([-\/\. _])(0?2)([-\/\. _])(29))|(^([1][89][0][48])([-\/\. _])(0?2)([-\/\. _])(29))|(^([2-9][0-9][0][48])([-\/\. _])(0?2)([-\/\. _])(29))|(^([1][89][2468][048])([-\/\. _])(0?2)([-\/\. _])(29))|(^([2-9][0-9][2468][048])([-\/\. _])(0?2)([-\/\. _])(29))|(^([1][89][13579][26])([-\/\. _])(0?2)([-\/\. _])(29))|(^([2-9][0-9][13579][26])([-\/\. _])(0?2)([-\/\. _])(29)))((\s+(0?[1-9]|1[012])(:[0-5]\d){0,2}(\s[AP]M))? $|(\s+([01]\d|2[0-3])(:[0-5]\d){0,2})? $))
ID number ^[1-9]\d{7}((0\d)|(1[0-2]))(([0|1|2]\d)|3[0-1])\d{3}$|^[1-9]\d{5}[1-9]\d{3}((0\d)|(1[0-2]))((0|1|2]\d)|3[0-1])\d{3}([0-9]|X)$)

Original content, reproduced with attribution: Smart Tool Kit

Comments (0 of)

Comments (0 of)

Suggestions and feedback Contact Us