Sort out several common Regular Expressions in C #
Source: Internet
Author: User
"^ \ D + $" // non-negative integer (positive integer + 0) "^ [0-9] * [1-9] [0-9] * $" // positive integer "^ (-\ D +) | (0 + )) $ "// non-positive integer (negative integer + 0)" ^-[0-9] * [1-9] [0-9] * $ "// negative integer" ^ -? \ D + $ "// integer" ^ \ D + (\. \ D + )? $ "// Non-negative floating point number (Positive floating point number + 0)" ^ ([0-9] + \. [0-9] * [1-9] [0-9] *) | ([0-9] * [1-9] [0-9] * \. [0-9] +) | ([0-9] * [1-9] [0-9] *) $ "// Positive floating point number" ^ (-\ D + (\. \ D + )?) | (0 + (\. 0 + )?)) $ "// Non-Positive floating point number (negative floating point number + 0)" ^ (-([0-9] + \. [0-9] * [1-9] [0-9] *) | ([0-9] * [1-9] [0-9] * \. [0-9] +) | ([0-9] * [1-9] [0-9] *) $ "// negative floating point number" ^ (-? \ D +) (\. \ D + )? $ "// Floating point number" ^ [A-Za-Z] + $ "// a string consisting of 26 English letters" ^ [A-Z] + $ "// consists of 26 A string consisting of uppercase letters "^ [A-Z] + $" // a string consisting of lowercase letters 26 "^ [A-Za-z0-9] + $" // composed A string consisting of a number and 26 English letters "^ \ W + $" // a string consisting of a number, 26 English letters, or underscores "^ [\ W-] + (\. [\ W-] +) * @ [\ W-] + (\. [\ W-] +) + $ "// email address" ^ [A-Za-Z] +: // (\ W + (-\ W + )*) (\. (\ W + (-\ W + )*))*(\? \ S *)? $ "// URL
Only numbers can be entered: "^ [0-9] * $". Only n digits can be entered: "^ \ D {n} $". Only n digits can be entered: "^ \ D {n ,}$" can only input m-N digits: "^ \ D {M, N }$" can only input numbers starting with zero and non-zero: "^ (0 | [1-9] [0-9] *) $" can only input positive numbers with two decimal places: "^ [0-9] + (. [0-9] {2 })? $ "Can only enter positive numbers with 1-3 decimal places:" ^ [0-9] + (. [0-9] {1, 3 })? $ "Only a non-zero positive integer can be entered:" ^ \ +? [1-9] [0-9] * $ "can only be a non-zero negative integer: "^ \-[1-9] [0-9] * $" can only contain 3 characters: "^. {3} $ "can only be a string consisting of 26 English letters:" ^ [A-Za-Z] + $ "can only be a string consisting of 26 uppercase English letters: '^ [A-Z] + $' can only enter a string consisting of 26 lower-case letters: "^ [A-Z] + $" can only be a string consisting of a number and 26 English letters: '^ [A-Za-z0-9] + $' can only enter a string consisting of digits, 26 English letters, or underscores: '^ \ W + $' to verify the user password: "^ [A-Za-Z] \ W {5, 17} $" is in the correct format: it must start with a letter and be between 6 and 18 characters. It can only contain characters, numbers, and underscores. Check whether ^ % & ',; =? $ \ "And other characters:" [^ % & ',; =? $ \ X22] + "only Chinese characters can be entered:" ^ [\ u4e00-\ u9fa5], {0,} $ "verification email address: "^ \ W + ([-+.] \ W +) * @ \ W + ([-.] \ W + )*\. \ W + ([-.] \ W +) * $ "verify interneturl:" ^ http: // ([\ W-] + \.) + [\ W-] + (/[\ W -. /? % & =] *)? $ "Verification phone number:" ^ (\ D {3, 4} \) | \ D {3, 4 }-)? \ D {7,8} $ is in the correct format: XXXX-XXXXXXX, XXXX-XXXXXXXX, XXX-XXXXXXX, XXX-XXXXXXXX, xxxxxxx, XXXXXXXX ". Verify the ID card number (15 or 18 digits): "^ \ D {15} | \ D {} 18 $" 12 months of a year: "^ (0? [1-9] | 1 [0-2]) $ "the correct format is:" 01 "-" 09 "and" 1 "" 12 "to verify the 31 days of a month: "^ (0? [1-9]) | (1 | 2) [0-9]) | 30 | 31) $ "the correct format is: "01" "09" and "1" "31 ".
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.
A Free Trial That Lets You Build Big!
Start building with 50+ products and up to 12 months usage for Elastic Compute Service