Latest mobile phone number regular expression (PHP version)

Source: Internet
Author: User
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! "); } } } }}

  • 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.