The magic regular expression can help us solve the format verification required. Commonly Used regular expressions include mobile phone numbers and passwords, and some of the regular expressions frequently used in projects are attached to record /**
* Mobile phone number
* Move: 134 [0-8], 135,136,137,138,139,150,151,157,158,159,182,187,188
* Unicom: 130,131,132,152,155,156,185,186
* China Telecom: 153,180,189
*/
NSString * MOBILE = @ "^ 1 (3 [0-9] | 5 [0-35-9] | 8 [025-9]) \ d {8} $ ";
/**
* China Mobile: China Mobile
* 134 [0-8], 135,136,137,138,139,150,151,157,158,159,182,187,188
*/
NSString * CM = @ "^ 1 (34 [0-8] | (3 [5-9] | 5 [017-9] | 8 [278]) \ d) \ d {7} $ ";
/**
* China Unicom: China Unicom
* 130,131,132,152,155,156,185,186
*/
NSString * CU = @ "^ 1 (3 [0-2] | 5 [256] | 8 [56]) \ d {8} $ ";
/**
* China Telecom: China Telecom
* 133,1349, 153,180,189
*/
NSString * CT = @ "^ 1 (33 | 53 | 8 [09]) [0-9] | 349) \ d {7} $ ";
/**
* Fixed telephones and PHS in Mainland China
* Area code: 010,020,021,022,023,024,025,027,028,029
* Number: seven or eight digits
*/
// NSString * PHS = @ "^ 0 (10 | 2 [0-5789] | \ d {3}) \ d {} $ ";
Password
^ (? = .*? [A-zA-Z]) (? = .*? [0-9]) [a-zA-Z0-9] {6, 20} $
"^ \ 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
Quantity
"^ (-? \ D +) (\. \ d + )? $ "// Floating point number
"^ [A-Za-z] + $" // A string consisting of 26 English letters
"^ [A-Z] + $" // a string consisting of 26 uppercase letters
"^ [A-z] + $" // a string consisting of 26 lowercase letters
"^ [A-Za-z0-9] + $" // string consisting of digits and 26 letters
"^ \ W + $" // a string consisting of digits, 26 letters, or underscores
"^ [\ W-] + (\. [\ w-] +) * @ [\ w-] + (\. [\ w-] +) + $ "// email address
"^ [A-zA-z] +: // (\ w + (-\ w + )*)(\. (\ w + (-\ w + )*))*(\? \ S *)? $ "// Url
/^ 13 \ d {9} $/gi mobile phone number Regular Expression
Public static bool isvalidinclueno (string inclueno)
{
Const string regPattern = @ "^ (130 | 131 | 132 | 133 | 134 | 135 | 136 | 137 | 138 | 139) \ d {8} $ ";
Return Regex. IsMatch (regioneno, regPattern );
}
Regular Expression -- verify mobile phone number: 13 [0-9] {9}
If the mobile phone number is 86 or + 86 before it is implemented: ^ (\ + 86) | (86 ))? (13) \ d {9} $
Verify the phone number and phone number at the same time: (^ (\ d {3, 4 }-)? \ D {7, 8}) $ | (13 [0-9] {9 })
Extract the network link in the information: (h | H) (r | R) (e | E) (f | F) * = * ('| ")? (\ W | \/| \.) + ('| "| * |> )?
Email Address in the extracted information: \ w + ([-+.] \ w +) * @ \ w + ([-.] \ w + )*\. \ w + ([-.] \ w + )*
Extract the image link in the information: (s | S) (r | R) (c | C) * = * ('| ")? (\ W | \/| \.) + ('| "| * |> )?
Extract the IP address in the information: (\ d +) \. (\ d +)
Extract the Chinese mobile phone number from the information: (86) * 0*13 \ d {9}
Extracted Chinese landline numbers from the information: (\ d {3, 4} \) | \ d {3, 4}-| \ s )? \ D {8}
Extract Chinese phone numbers (including mobile and landline phones) from the Information: (\ d {3, 4} \) | \ d {3, 4}-| \ s )? \ D {7, 14}
Extracted Chinese zip code: [1-9] {1} (\ d +) {5}
Chinese ID card number in the extracted information: \ d {18} | \ d {15}
Extract the integer in the information: d +
Extract floating point numbers (decimal places) in the Information ):(-? \ D *)\.? \ D +
Extract any number from the information :(-? \ D *) (\. \ d + )?
Extract the Chinese string from the information: [\ u4e00-\ u9fa5] *
Double-byte string (Chinese character) in the extracted information: [^ \ x00-\ xff] *