Mobile phone number, password regular verification _javascript tips

Source: Internet
Author: User

/**
* 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
* Telecom: 133,1349,153,180,189
*/
NSString * MOBILE = @ "^1 (3[0-9]|5[0-35-9]|8[025-9]) \\d{8}$";
/**
* 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: Chinese Unicom
* 130,131,132,152,155,156,185,186
*/
NSString * CU = @ "^1 (3[0-2]|5[256]|8[56]) \\d{8}$";
/**
* China Telecom: Chinese Telecom
* 133,1349,153,180,189
*/
NSString * CT = @ "^1 ((33|53|8[09)) [0-9]|349) \\d{7}$";
/**
* Fixed and PHS in mainland area
* Area code: 010,020,021,022,023,024,025,027,028,029
* Number: seven-or eight-bit
*/
NSString * PHS = @ "^0 (10|2[0-5789]|\\d{3}) \\d{7,8}$";

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+)? $"//nonnegative floating-point number (positive float + 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 of 26 English letters 
"^[a-z]+$"//A string of 26 uppercase letters 
"^[a-z]+$"///a string consisting of 26 lowercase letters 
"^[a-za-z0-9]+$"//A string of numbers and 26 English letters 
"^\w+$"//A string of numbers, 26 English letters, or underscores 
"^[\w-]+ (\.[ \w-]+) *@[\w-]+ (\.[ \w-]+) +$ "//email address 
"^[a-za-z]+://(\w+ (-\w+) *) (\. ( \w+ (-\w+) *)) * (\?\s*) $ "//url 
/^13\d{9}$/gi cell phone number Regular expression


public static bool Isvalidmobileno (string mobileno)

Const string Regpattern = @ "^ (130|131|132|133|134|135|136|137|138|139) \d{8}$";  
Return Regex.IsMatch (Mobileno, Regpattern);  
}


Regular expression--verification of mobile phone number: 13[0-9]{9} 
To achieve the mobile phone number 86 or +86 before: ^ (\+86) | (86))? (\d{9}$) 
The phone number and mobile number are verified simultaneously: (^ (\d{3,4}-) \d{7,8}) $| (13[0-9]{9}) 
To extract the network links in the information: (h| H) (r| R) (e| E) (f| F) *= * (' | ')? (\w|\\|\/|\.)  +('|"| *|>)? 
Message address in the extraction information: \w+ ([-+.] \w+) *@\w+ ([-.] \w+) *\.\w+ ([-.] \w+) * 
Extract picture links in information: (s| S) (r| R) (c| C) *= * (' | ')? (\w|\\|\/|\.)  +('|"| *|>)? 
Extract the IP address in the information: (\d+) \. (\d+) \. (\d+) \. (\d+) 
China Mobile phone number to extract information: (*0*13\D{9) 
Extract Chinese fixed phone number in information: (\ (\d{3,4}\) |\d{3,4}-|\s)? \d{8} 
Extract the Chinese phone number (including mobile and landline) in the information:(\ (\d{3,4}\) |\d{3,4}-|\s)? \d{7,14} 
China Post Code in Extract information: [1-9]{1} (\d+) {5} 
Chinese identity card number in the extraction of information: \d{18}|\d{15} 
To extract an integer from the information: \d+ 
Extract floating-point numbers (that is, decimals) in the information: (-?\d*) \.? \d+ 
Extract any number in the information: (-?\d*) (\.\d+)? 
Extract the Chinese string in the information: [\u4e00-\u9fa5]* 
Extract a double-byte string (kanji) from the information: [^\x00-\xff]* 

Contact Us

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

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.