Mobile phone number, name (including minority), ID number verified by Android regular expression.

Recently, mobile phone name, ID number and other information are needed to verify the new function. The best way is to verify by regular expression, and check some information on the Internet, and write these tools.

1. Verify phone number

Rule: the first digit can only be 1, the second digit is a number in 3-8, and the third-11 digits are any number

2. Verify name here to verify the name. The user can enter anything in the input box, but this method will be called when clicking the verify button.

The verification rule is: the name is composed of Chinese characters or Chinese characters plus "•" and "•", and there can only be one "point", and the position of "point" cannot be in the first place or at the end. The verification will pass only between Chinese characters.

3. Verify the ID number.

Verify ID number

The rule is: it is composed of 15 digits or 18 digits (17 digits plus "X"). There is nothing to say about 15 pure digits. If 18 digits, it can be 18 pure digits or 17 digits plus "X"

The above regular expression verification results are returned through true and false

The above is the whole content of this article. I hope the content of this article can bring some help to your study or work. At the same time, I also hope to support a lot of programming tips!

The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
分享
二维码
< <上一篇
下一篇>>