Home >Web Front-end >JS Tutorial >Mobile phone number, password regular verification_javascript skills
/**
* Mobile number
* Move: 134[0-8],135,136,137,138,139,150,151,157,158,159,182,187,188
* China 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}$";
/**
* 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}$";
/**
* Landline 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{7,8}$";
code
^(?=.*?[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
Number
"^(-?d )(.d )?$" //Floating point number
"^[A-Za-z] $" //A string consisting of 26 English letters
"^[A-Z] $" //A string consisting of 26 uppercase English letters
"^[a-z] $" //A string consisting of 26 lowercase English letters
"^[A-Za-z0-9] $" //A string consisting of numbers and 26 English letters
"^w $" //A string consisting of numbers, 26 English letters or underscores
"^[w-] (.[w-] )*@[w-] (.[w-] ) $" //email address
"^[a-zA-z] ://(w (-w )*)(.(w (-w )*))*(?S*)?$" //url
/^13d{9}$/giMobile 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 - Verify mobile phone number: 13[0-9]{9}
Implement the situation of adding 86 or 86 in front of the mobile phone number: ^(( 86)|(86))?(13)d{9}$
Phone number and mobile phone number are verified at the same time: (^(d{3,4}-)?d{7,8})$|(13[0-9]{9})
Extract network links in the information: (h|H)(r|R)(e|E)(f|F) *= *('|")?(w|\|/|.) ('|"| *|>)?
Extract the email address in the message: w ([- .]w )*@w ([-.]w )*.w ([-.]w )*
Extract the picture link in the information: (s|S)(r|R)(c|C) *= *('|")?(w|\|/|.) ('|"| *|>) ?
Extract the IP address in the information: (d).(d).(d).(d)
Extract the Chinese mobile phone number in the information: (86)*0*13d{9}
Extract the Chinese landline phone number in the information: ((d{3,4})|d{3,4}-|s)?d{8}
Extract Chinese phone numbers from the information (including mobile and landline phones): ((d{3,4})|d{3,4}-|s)?d{7,14}
Extract the Chinese postal code in the information: [1-9]{1}(d){5}
Extract the Chinese ID number from the information: d{18}|d{15}
Extract integers from information: d
Extract floating point numbers (i.e. decimals) in the information: (-?d*).?d
Extract any number in the message: (-?d*)(.d)?
Extract the Chinese string in the information: [u4e00-u9fa5]*
Extract the double-byte string (Chinese characters) in the message: [^x00-xff]*