PHP and JS mailbox validation Regular expression

Source: Internet
Author: User
Tags php and regular expression

PHP Mailbox Validation Regular expression

The code is as follows Copy Code
Preg_match ("/^[0-9a-za-z]+@" ([0-9a-za-z]+) [.]) +[a-z]{2,4}$/i ", $email);


Example of a PHP mailbox validation regular expression

The code is as follows Copy Code


<?php
function Isemail ($email) {
if (Preg_match (/^[0-9a-za-z]+@ ([0-9a-za-z]+) [.]) +[a-z]{2,4}$/i ", $email)) {
Return ' mailbox verification OK ';
} else {
Return ' verify not mailbox ';
}
}
?>


Myreg =/^ ([a-za-z0-9]+[_|_|.]?) *[a-za-z0-9]+@ ([a-za-z0-9]+[_|_|.]?) *[a-za-z0-9]+. [A-za-z] {2,4}$/

Example of a mailbox validation regular expression

Example 1

The code is as follows Copy Code

<script type= "Text/javascript" >
Function Isemail (val) {
var myreg =/^ ([a-za-z0-9]+[_|_|.]?) *[a-za-z0-9]+@ ([a-za-z0-9]+[_|_|.]?) *[a-za-z0-9]+. [A-za-z] {2,4}$/;

if (!myreg.test (val))
Return ' not a mailbox ';
Return ' is the mailbox ';
};
Alert (Isemail (' i@fufuok.com '));
</script>

Example 2

  code is as follows copy code

/**
  * Email format Verification
 * @param {Object} email address content
 */
function emailformatcheck (email) {
     if ((Email.length > 128) | | (Email.length < 6)) {
        return false;
   }
    var format =/^[a-za-z0-9+]+[a-za-z0-9._-+]*@ ([a-za-z0-9-]+.) +[a-za-z0-9]+$/;
    if (!email.match (format)) {
        return false;
& nbsp;  }
    return true;
}

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.