Function | Regular Expression |
---|---|
Integer (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 | ^([+-]?)\\d *\\.\d +$ |
Positive floating-point | ^[1-9]\\d *.\\d * | 0.\d *[1-9]\d * | 0?.0 + | 0$ |
Negative floating-point | ^(-([1-9]\d *.\d * | 0.\d *[1-9]\d *) | 0?.0 + | 0$ |
Non-negative floats (positive floats +0, keep one decimal place) | ^(([0-9]+\.[0-9]{1})|([0-9]*[1-9][0-9]*\.[0-9]{1})|([0-9]*[0-9]{1}))$ |
^[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])?)*$ | |
color | ^[a-fA-F0-9]{6}$ |
url | ^ http[s]?:\\/\\/([\\w-]+\\.)+[\\w-]+([\\w-./?%&=]*)?$ |
Chinese only | ^[\\u4E00-\\u9FA5\\uF900-\uFA2D]+$ |
ACSII characters only | ^[\\x00-\xFF]+$ |
^\\ d{6}$ | |
mobile number | ^(11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19)[0-9]{9}$ |
Mobile 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-null | ^^\\ S +$ |
Letters | ^[A-Za-z]+$ |
Only uppercase letters | ^[A-Z]+$ |
Only lowercase letters | ^[a-z]+$ |
Password (must contain numbers, letters, special characters, and 6-12 digits in length). | ^(?! \D+$) (?! [a-zA-Z0-9]+$)(?! [a-zA-Z0-9]+$)\S{6,12}$ |
^(?! \D+$) (?! [^ a-z]+$)\S{8,12}$ | |
Password (must contain numbers, uppercase letters, lowercase letters, special characters and a length of 6-12) | ^(?! \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)([-\/\._])(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, reprint please indicate the source: smart tool library