How to write a regex in php to verify email and mobile phone number at the same time?
習慣沉默
習慣沉默 2017-05-16 13:06:44
0
3
723

php verifies email and mobile phone number at the same time

Need a regular expression that can match both mobile phone numbers and email accounts

習慣沉默
習慣沉默

reply all(3)
漂亮男人

First use /^[0-9]*$/ to determine whether it is a pure number. If it is, enter the logic of mobile phone number verification. Use /^1[3|4|5|7|8]d{9}$ / to verify whether it is a legal mobile phone number.

If it is not a pure number, enter the logic of email verification. /^w+((-w+)|(.w+))@[A-Za-z0-9]+((.|-)[A-Za- z0-9]+).[A-Za-z0-9]+$/ can be used to verify email

巴扎黑

Use this to verify the email address, and then when it returns false, use the regular pattern to verify the mobile phone number, like this.
$email = 'fengdingbo@gmail.com';
$result = filter_var($email, FILTER_VALIDATE_EMAIL);
var_dump($result); // string(20) "fengdingbo@gmail.com"

伊谢尔伦

It’s a bit loose to verify email and mobile phone number at the same time. You can take a look at the example below

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template