# Set of regular expressions

Time：2019-12-2

### I. expression of verification number

1. Number: ^ [0-9]$2. N digits: ^ \ D {n}$
3. At least n digits: ^ \ D {n,}$4. M-N digits: ^ \ D {m, n}$
5. Zero and non-zero digits: ^ (0| [1-9] [0-9])$6. The number with two decimals at most at the beginning of non-zero: ^ ([1-9] [0-9]) + (. [0-9] {1,2})$
7. A positive or negative number with 1-2 decimal places: ^ (-)) \ D + (. \ D {1,2})$8. Positive, negative, and decimal: ^ (- | +)? \ D + (. \ D +)$
9. A positive real number with two decimal places: ^ [0-9] + (. [0-9] {2})$10. A positive real number with 1-3 decimal places: ^ [0-9] + (. [0-9] {1,3})$
11. Nonzero positive integer: ^ [1-9] \ d $or ^ ([1-9] [0-9]) {1,3}$or ^ +? [1-9] [0-9]$12. Nonzero negative integer: ^ – [1-9] [] 0-9 “$or ^ – [1-9] \ D$13. Nonnegative integer: ^ \ D +$or ^ [1-9] \ d| 0$14. Non positive integer: ^ – [1-9] \ d| 0$or ^ ((- \ D +) | (0 +))$15. Non negative floating-point number: ^ \ D + (. \ D +)?$or ^ [1-9] \ D. \ d| 0. \ d [1-9] \ d| 0 × 0 + | 0$16. Non positive floating-point number: ^ ((- \ D + (. \ D +)) | (0 + (. 0 +)))$or ^ (([1-9] \ D. \ d| 0. \ d [1-9] \ d)) |. 0 + |.0$17. Positive 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])$18. 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]))$19. Floating point number: ^ (-? \ D +) (. \ D +)?$or ^ -? ([1-9] \ D. \ d|0. \ d [1-9] \ d|0?. 0 + |0)$### 2. Expression of check character 1. Chinese characters: ^ [\ u4e00 – \ u9fa5] {0,}$
2. English and numbers: ^ [a-za-z0-9] + $or ^ [a-za-z0-9] {4,40}$
3. All characters 3-20 in length: ^. {3,20}$4. A 26 letter string: ^ [a-za-z]+$
5. A string of 26 uppercase letters: ^ [A-Z]+$6. A string of 26 lowercase letters: ^ [A-Z]+$
7. A string of numbers and 26 English letters: ^ [a-za-z0-9]+$8. A string of numbers, 26 letters, or underscores: ^ \ W +$or ^ \ w {3,20}$9. Chinese, English and numbers include underscores: ^ [\ u4e00 – \ u9fa5a-za-z0-9]+$
10. Chinese, English, numbers but excluding underscores and other symbols: ^ [\ u4e00 – \ u9fa5a-za-z0-9] + $or ^ [\ u4e00 – \ u9fa5a-za-z0-9] {2,20}$
11. You can enter characters such as ^% & ‘,; =? $\’: [^% & ‘,; =?$\ X22]+
12. Characters with ~ are not allowed: [^ ~ \ X22]+
13. Input format of money:
• There are four forms of money we can accept: “10000.00” and “10000.00”, and “10000” and “10000” without “points”: ^ [1-9] [0-9]$• 1 to 3 numbers, followed by any comma + 3 numbers, comma becomes optional, instead of being required: ^ ([0-9] + | [0-9] {1,3} (, [0-9] {3})) (. [0-9] {1,2})?$note: This is the final result, do not forget that “+” can be used“

14. X M L file: ^ ([a-za-z] + -?) + [a-za-z0-9] + \. [x|x] [m|m] [l|l]$15. Regular expression of Chinese characters: [\ u4e00 – \ u9fa5] 16. Double byte character: [^ \ X00 – \ XFF] [including Chinese characters, it can be used to calculate the length of string (one double byte character length meter 2, ASCII character meter 1)) 17. Regular expression of blank line: \ n \ s \ R [can be used to delete blank line] 18. Regular expression of HTML tag:] >.? | [the version circulated on the Internet is too bad, and the above is only partial, but it is still unable to do anything for complex nested tags]] 19. Regular expression of the first and last blank characters: ^ \ s| \ S$or (^ \ s) | (\ s * $) [it can be used to delete the blank characters at the beginning and end of the line (including spaces, tabs, page breaks, etc.), which is very useful 20. Tencent QQ number: [1-9] [0-9] {4,} [Tencent QQ number starts from 10000] 21. Postcode of China: [1-9] \ D {5} (?) (!) [postcode of China is 6 digits] 22. IP address: \ D +. \ D +. \ D +. \ D + [useful when extracting IP address] ### III. expression of special requirements 1. Email address: ^ \ W + ([- +.] \ W +) @ \ W + ([-.] \ W +). \ W + ([-.] \ W +)*$
2. Domain name: [a-za-z0-9] [a-za-z0-9] {0,62} (/. [a-za-z0-9] [a-za-z0-9] {0,62}) + /?
3. Interneturl: [a-za-z] +: / / [^ \ S] or ^ [http: / / ([\ W -] + \) + [\ W -] + (/ [\ W -. /?% &) =) $] (http: / /% 2528% 5B / W -% 5D + /.% 2529 +% 5B / W -% 5D +% 2528 /% 5B / W -. /?% 25 & =% 5D *% 2529?$)
4. Mobile number: ^ (13 [0-9] | 14 [5| 7] | 15 [0| 1| 2| 3| 5| 6| 7| 8| 9] | 18 [0| 1| 2| 3| 5| 6| 8| 9]) \ D {8}$5. Phone numbers (“xxx-xxxxxxx”, “xxxx-xxxxxxx”, “xxx-xxxxxxx”, “xxx-xxxxxxx”, “XXXXXXX” and “XXXXXXXX): ^ ((\ D {3,4}-) | \ D {3.4}-)? \ D {7,8}$
6. Domestic phone number (0511-4405222, 021-87888822): \ D {3}- \ D {8}| \ D {4}- \ D {7}
7. ID number:
• 15 or 18 digit ID card: ^ \ D {15}| \ D {18}$• 15 ID cards: ^ [1-9] \ D {7} ((0 \ d) | (1 [0-2]) (([0| 1| 2] \ d) | 3 [0-1]) \ D {3}$
• 18 ID cards: ^ [1-9] \ D {5} [1-9] \ D {3} ((0 \ d) | (1 [0-2]) (([0| 1| \ d) | (3 [0-1]) \ D {4}$• Short ID number (number, end of letter X): ^ ([0-9]) {7,18} (x| x)?$or ^ \ D {8,18}| [0-9x] {8,18}| [0-9x] {8,18}$• Whether the account number is legal (starting with a letter, 5-16 bytes allowed, alphanumeric underline allowed): ^ [a-za-z] [a-za-z0-9 “{4,15}$
• Password (starting with a letter, between 6 and 18, only letters, numbers and underscores): ^ [a-za-z] \ w {5,17}$• Strong password (must contain a combination of uppercase and lowercase letters and numbers. Special characters are not allowed. The length is between 8-10): ^ (? =. [A-Z]) (? =. [A-Z]) (? * [A-Z]). {8,10}$
• Date format: ^ \ D {4} – \ D {1,2} – \ D {1,2}
• 12 months of a year (01-09 and 1-12): ^ (0? [1-9] | 1 [0-2])$• 31 days of a month (01-09 and 1-31): ^ ((0? [1-9]) | ((1| 2) [0-9]) | (30| 31)$

## How to search files or directories under CentOS

Search for files or directories: The search for files is great! Because we often need to know where that file is, let’s talk about how to search it! There are also quite excellent ones under Linux Search system! Usually find is not very common! Because the speed is slow, but also very hard disk! Usually […]