| In this paper, the use of regular expressions to verify the mobile phone number method, you can verify the latest mobile phone number segment, including 150, 158, 159, 188 and so on. Please refer to the friends who are in need. Before, the programmer's home, introduced some of the regular to verify the mobile phone number, such as: PHP matches the phone number of regular expressions (support location, live number, extension) PHP Common regular expressions (date phone Chinese mailbox, etc.) but now the number of mobile phones increased by 150, 153,156,158,159,157,188,189 equals segment, which complements the relevant regular expression. As follows: Copy Codecode example: string s = @ "^ (13[0-9]|15[0|3|6|7|8| 9]|18[8|9]) \d{8}$ ";Add 180,147 and more: Copy Codecode example: ^ (1 ([35][0-9]) | ( 47) | [8] [0126789])) \d{8}$Again modified added 183, and added a landline, as follows: Copy Codecode example: Mobile: ^ (1 ([35][0-9]) | ( 47) | [8] [01236789])) \d{8}$ Landline: ^0\d{2,3} (\-)? \d{7,8}$The following is an example of verifying a mobile phone number with two regular expressions used in PHP and Java. Version 1,php Copy Codecode example: Version 2,java Copy Codecode example:Using system;using system.collections.generic;using system.text;using system.text.regularexpressions;using System.Windows.Forms; Namespace consoleapplication1{class Program {static void Main (string[] args) {//String s = @ "^ (13[0-9]|15[0|3|6|8| 9]) \d{8}$ "; string s = @ "^ (13[0-9]|15[0|3|6|7|8| 9]|18[8|9]) \d{8}$ "; while (true) {string input = Console.ReadLine (); if (Regex.IsMatch (input, s)) {MessageBox.Show ("fully compliant! "); } else {MessageBox.Show ("does not match! "); } } } }} |