Home > Backend Development > PHP Tutorial > The latest mobile phone number regular expression (php version)

The latest mobile phone number regular expression (php version)

WBOY
Release: 2016-07-25 08:58:04
Original
1910 people have browsed it
This article introduces how to use regular expressions to verify mobile phone numbers, which can verify the latest mobile phone number segments, including 150, 158, 159, 188, etc. Friends in need can refer to it.

Before, Programmer’s Home introduced some regular rules for verifying mobile phone numbers, such as: php regular expression for matching phone numbers (supports location, live broadcast number, extension number) Commonly used regular expressions in php (date, phone, Chinese, email, etc.) However, now the mobile phone number has added 150, 153, 156, 158, 159, 157, 188, 189 and other number segments. Here are the relevant regular expressions. as follows:

Copy code Code example: string s = @"^(13[0-9]|15[0|3|6|7|8|9]|18[8|9])d{8}$";

Add 180, 147, etc.:

Copy code Code example: ^(1(([35][0-9])|(47)|[8][0126789]))d{8}$

Modify again and add 183, and add landline, as follows:

Copy code Code example: Mobile phone: ^(1(([35][0-9])|(47)|[8][01236789]))d{8}$ Landline: ^0d{2,3}(-)?d{7,8}$

The following is an example of two regular expressions used in php and java to verify mobile phone numbers.

1, php version

Copy code Code example:

2, java version

Copy code Code 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("Completely consistent!"); } else { MessageBox.Show("Does not match!"); } } } } }



source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template