About copying the phone number in the Address book on the iOS system, and the user's regular expression verifies that the phone number doesn't pass.

Source: Internet
Author: User

This is the cell phone number I copied on the iOS11 system and sent to the nail.

You will find that in addition to the middle of the 2 spaces, the final appearance also has a space, but when you copy it into the editor when the space is not, when you click the left and right arrow keys on the keyboard to move the cursor, you will find that the cursor at the end of the mobile phone number to stop to move, This indicates that there is a non-placeholder symbol at the end of the phone number. I copied the phone number to the console and I printed the length.

Rationale 11-digit phone number plus the middle 2 spaces should be 13 bits, but now the length is 14 bits.

I copied it down and encoded it with a URL.

Before encoding:

After encoding:

There was such a string.

So, all I'm thinking about is this approach.

var str = ' 177 1080 2725? '; var reg = new RegExp ("?", ""); var a = Str.replace (Reg, ""); Console.log (a.length);

Run as follows:

Succeeded, the length of STR became 13. Then the following will be happy to carry out the mobile phone number of the regular verification.

About copying the phone number in the Address book on the iOS system, and the user's regular expression verifies that the phone number doesn't pass.

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.