Common regular expression

xiaoxiao2021-04-07  290

1. Only enter numbers: "^ [0-9] * $"

2. Only enter N-bit numbers: "^ / D {n} $"

3. Only at least N digits can be entered: "^ / d {n,} $"

4. You can only enter the number of m-n bits: "^ / d {m, n} $"

5. You can only enter the numbers of zero and non-zero: "^ (0 | [1-9] [0-9] *) $"

6. You can only enter the right number of two decimals: "^ [0-9] (. [0-9] {2})?"

7. You can only enter a positive real number of 1-3 digits: "^ [0-9] (. [0-9] {1, 3})?"

8. You can only enter non-zero positive integers: "^ / ? [1-9] [0-9] * $"

9. You can only enter non-zero negative integers: "^ / - [1-9] [0-9] * $"

10. You can only enter the length of 3: "^. {3} $"

11. You can only enter a string consisting of 26 English letters: "^ [A-ZA-Z] $"

12. You can only enter a string consisting of 26 uppercase English letters: "^ [a-z] $"

13. You can only enter a string consisting of 26 lowercase English letters: "^ [a-z] $"

14. You can only enter a string consisting of numbers and 26 English letters: "^ [A-ZA-Z0-9] $"

15. You can only enter a string consisting of numbers, 26 English letters or underscores: "^ / w $"

Verify the user password: "^ [A-ZA-Z] / w {5, 17} $" correct format is: starting with letters, between 6-18,

16. Only characters, numbers, and underscores can be included. Verify whether it contains characters such as ^% & ',; =? $ / ":" [^% &',; =? $ / X22] "17. Can only enter Chinese characters:" ^ [/ u4e00- / u9fa5], {0,} $ "18. Verify Email Address:" ^ / W [- .] / W ) * @ / w ([-.] / W ) * /. / W ([-.] / W ) * $ "19. Verify InternetURL:" ^ http: // ([/ w-] /.) [/ W-. /%% = = = *)? "20. 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". 21. Verify the ID card number (15 or 18 digits): "^ / d {15} | / d {} 18 $" 22. Verify a year of 12 months: "^ (0? [1-9] | 1 [0-2]) $ "The correct format is:" 01 "-" 09 "and" 1 "" 12 "23. Verify a month of 31 days:" ^ ((((((((((0? [1-9]) | ((1 | 2) [0-9]) | 30 | 31) $ "

The correct format is: "01" "09" and "1" "31".

24. Verification Date format: YYYY-MM-DDRQ = // D {4} - {1} / d {1, 2} - {1} / d {1, 2} $ /;

转载请注明原文地址:https://www.9cbs.com/read-132577.html

New Post(0)