Table of Contents
回复讨论(解决方案)
Home Backend Development PHP Tutorial 手机号码正则表达式

手机号码正则表达式

Jun 23, 2016 pm 01:52 PM
phone number regular expression

 /**
    * 匹配手机号码
    * 1 3
    *       0123456789
    *   4
    *       57
    *   5
    *       0123456789
    *   7
    *   8
    **/
    $number = '13956789032';

    $pattern = '/1(3\d|4\[57]|5\d|7[01]|8\d)\d{8}/';

    if(preg_match($pattern ,$number ,$arr)){
    
        var_dump($arr);
    


回复讨论(解决方案)

so  ,你遇到什么问题了?

手机号11位数字,简单点的就是\d{11}
如果要更加严谨,那就判断手机号的前缀。

但你这个正则已经很好了,可以判断到 15X  13X  18X   其它的没有了什么好的建议了。

有没有更加完整的验证,说思路就行

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

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

AI Hentai Generator

AI Hentai Generator

Generate AI Hentai for free.

Hot Article

R.E.P.O. Energy Crystals Explained and What They Do (Yellow Crystal)
2 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
Repo: How To Revive Teammates
4 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
Hello Kitty Island Adventure: How To Get Giant Seeds
3 weeks ago By 尊渡假赌尊渡假赌尊渡假赌

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

How to check what is registered with a mobile phone number 'Detailed explanation: APP query method for mobile phone number registration' How to check what is registered with a mobile phone number 'Detailed explanation: APP query method for mobile phone number registration' Feb 07, 2024 am 08:24 AM

I don’t know if you have such an experience. Your mobile phone often receives some inexplicable text messages, or registration information for some websites or other verification information. In fact, our mobile phone number may be bound to many unfamiliar websites, and we ourselves Even if you don’t know, what I will share with you today is to teach you how to unbind all unfamiliar websites with one click. Step 1: Open the number service platform. This technique is very practical. The steps are as follows: Open WeChat, click the plus icon in the search box, select Add Friend, and then enter the code number service platform to search. We can see that there is a number service platform. Of course, it belongs to a public institution and was launched by the National Institute of Information and Communications Technology. It can help everyone unbind mobile phone number information with one click. Step 2: Check whether the phone has been marked for me

How to change the mobile phone number of Amap - Detailed introduction to the method of changing the mobile number of Amap How to change the mobile phone number of Amap - Detailed introduction to the method of changing the mobile number of Amap Mar 20, 2024 pm 08:41 PM

Amap is loved by users for its precise positioning and rich functions. However, during use, sometimes we may need to change the bound mobile phone number to ensure the accuracy of personal information and services. So, how to change the mobile phone number of Amap? The editor has compiled some relevant information, come and take a look with me! How to change the mobile phone number on Amap? Answer: [Amap]-[My]-[Settings Icon]-[Account and Security]-[Mobile Number]-[Change]-[Next Step]. Specific steps: 1. First open the Amap software and enter the home page. We need to click [My] in the lower right corner; 2. Then you can see some related functions in My One Second. Here we click on the upper right corner. [Settings icon] in the corner;

How to check the usage status of mobile phone number? How to check the usage time of mobile phone number? How to check the usage status of mobile phone number? How to check the usage time of mobile phone number? Mar 07, 2024 pm 04:30 PM

With the continuous advancement of mobile communication technology, mobile phone numbers have become an indispensable communication tool in our daily lives. Sometimes, we need to check the usage status of a mobile phone number, such as verifying whether the number is out of service or in arrears. 1. How to check the usage status of mobile phone number? Contacting the operator's customer service is the most direct way to check the usage status of your mobile phone number. Different operators may have different inquiry methods, but this can usually be accomplished by calling the operator's customer service hotline. When talking to customer service staff, you only need to provide the mobile phone number you need to query, and the customer service staff will provide you with detailed usage status information. Therefore, if you want to know the specific situation of a certain mobile phone number, you can get relevant information by calling the operator's customer service hotline. There are

How to change the mobile phone number binding in QQ mailbox - How to change the mobile phone number binding in QQ mailbox How to change the mobile phone number binding in QQ mailbox - How to change the mobile phone number binding in QQ mailbox Mar 04, 2024 pm 03:46 PM

Many friends don’t know how to change the mobile phone number binding in QQ mailbox, so the editor below will share the method of changing the mobile phone number binding in QQ mailbox. Let’s follow the editor to take a look. I believe it will be helpful to everyone. Step 1: First open the QQ mailbox and select the settings above, as shown below. Step 2: Select the account option in the settings, as shown below. Step 3: Choose to log out immediately, as shown below. Step 4: After logging out, choose to register a mobile phone number and email account. Step 5: Choose to register other accounts in the interface that appears, as shown below. Step 6: Use the new mobile phone number according to the prompts and send text messages, as shown below. Step 7: After the sending is completed, the change is successful. The above is the entire content of how to change the mobile phone number binding in QQ mailbox brought to you by the editor. I hope

PHP regular expressions: exact matching and exclusion of fuzzy inclusions PHP regular expressions: exact matching and exclusion of fuzzy inclusions Feb 28, 2024 pm 01:03 PM

PHP Regular Expressions: Exact Matching and Exclusion Fuzzy inclusion regular expressions are a powerful text matching tool that can help programmers perform efficient search, replacement and filtering when processing text. In PHP, regular expressions are also widely used in string processing and data matching. This article will focus on how to perform exact matching and exclude fuzzy inclusion operations in PHP, and will illustrate it with specific code examples. Exact match Exact match means matching only strings that meet the exact condition, not any variations or extra words.

PHP regular expression validation: number format detection PHP regular expression validation: number format detection Mar 21, 2024 am 09:45 AM

PHP regular expression verification: Number format detection When writing PHP programs, it is often necessary to verify the data entered by the user. One of the common verifications is to check whether the data conforms to the specified number format. In PHP, you can use regular expressions to achieve this kind of validation. This article will introduce how to use PHP regular expressions to verify number formats and provide specific code examples. First, let’s look at common number format validation requirements: Integers: only contain numbers 0-9, can start with a plus or minus sign, and do not contain decimal points. floating point

How to validate email address in Golang using regular expression? How to validate email address in Golang using regular expression? May 31, 2024 pm 01:04 PM

To validate email addresses in Golang using regular expressions, follow these steps: Use regexp.MustCompile to create a regular expression pattern that matches valid email address formats. Use the MatchString function to check whether a string matches a pattern. This pattern covers most valid email address formats, including: Local usernames can contain letters, numbers, and special characters: !.#$%&'*+/=?^_{|}~-`Domain names must contain at least One letter, followed by letters, numbers, or hyphens. The top-level domain (TLD) cannot be longer than 63 characters.

Master regular expressions and string processing in Go language Master regular expressions and string processing in Go language Nov 30, 2023 am 09:54 AM

As a modern programming language, Go language provides powerful regular expressions and string processing functions, allowing developers to process string data more efficiently. It is very important for developers to master regular expressions and string processing in Go language. This article will introduce in detail the basic concepts and usage of regular expressions in Go language, and how to use Go language to process strings. 1. Regular expressions Regular expressions are a tool used to describe string patterns. They can easily implement operations such as string matching, search, and replacement.

See all articles