我要的是正则表达式来验证[email protected][email protected];[email protected];[email protected]都是合法的EMAIL地址

解决方案 »

  1.   

    <script>
    function isEmail(strEmail) {
     if (strEmail.search(/^\w+((-\w+)|(\.\w+))*\@[A-Za-z0-9]+((\.|-)[A-Za-z0-9]+)*\.[A-Za-z0-9]+$/) != -1)
      return true;
     else
      alert("oh");
    }
    </script>
      

  2.   

    use the format like
    email(\s*;\s*email)*oremail(?:\s*;\s*email)*so taken the email regular expression from
    www.regexlib.com
    (enter "email" in the keyword textbox and click on the Search button, the fifth expression from the output):^[\w-]+(\.[\w-]+)*@([a-z0-9-]+(\.[a-z0-9-]+)*?\.[a-z]{2,6}|(\d{1,3}\.){3}\d{1,3})(:\d{4})?$ 
    you will have something like^[\w-]+(\.[\w-]+)*@([a-z0-9-]+(\.[a-z0-9-]+)*?\.[a-z]{2,6}|(\d{1,3}\.){3}\d{1,3})(:\d{4})?
    (?:\s*;\s*[\w-]+(\.[\w-]+)*@([a-z0-9-]+(\.[a-z0-9-]+)*?\.[a-z]{2,6}|(\d{1,3}\.){3}\d{1,3})(:\d{4})?)*$  or use fason's regex, you will get^\w+((-\w+)|(\.\w+))*\@[A-Za-z0-9]+((\.|-)[A-Za-z0-9]+)*\.[A-Za-z0-9]+(?:\s*;\s*\w+((-\w+)|(\.\w+))*\@[A-Za-z0-9]+((\.|-)[A-Za-z0-9]+)*\.[A-Za-z0-9]+)*$
      

  3.   

    <script>
    function isEmail(strEmail) {
     if (strEmail.search(/^\w+((-\w+)|(\.\w+))*\@[A-Za-z0-9]+((\.|-)[A-Za-z0-9]+)*\.[A-Za-z0-9]+$/) != -1)
      return true;
     else
      alert("oh");
    }
    </script>
      

  4.   

    <?php 
    function emailIsRight($email) { 
    if (preg_match("^[_\.0-9a-z-]+@([0-9a-z][0-9a-z-]+\.)+[a-z]{2,3}$",$email)) { 
    return 1; 

    return 0; 

    if(emailIsRight('[email protected]')) echo '正确<br>'; 
    if(!emailIsRight('y10k@fffff')) echo '不正确<br>'; 
    ?>