本帖最后由 kksse 于 2009-12-28 17:19:49 编辑

解决方案 »

  1.   

    var datas = ['[email protected]',
    'a',
    '[email protected],[email protected],[email protected]',
    'a,b,c',
    'a,[email protected],c'];function remendinput(oInput) {
        oInput = oInput.replace(/(^|,)(\w+(\.\w+)?)(?!@)/g, "[email protected]");
        //document.getElementById("ss").value = oInput;
        document.write(oInput + '<br/>');
    }document.open();  
    for (var i = 0; i < datas.length; i++) {
        remendinput(datas[i]);    
    }
    document.close();
      

  2.   

    使用此表达式,会对@前超过1个字符的邮件地址判断错误。输入结果:[email protected]@xxx.com
    var datas = ['[email protected]'];function remendinput(oInput) {
        oInput = oInput.replace(/(^|,)(\w+(\.\w+)?)(?!@)/g, "[email protected]");
        //document.getElementById("ss").value = oInput;
        document.write(oInput + '<br/>');
    }document.open();  
    for (var i = 0; i < datas.length; i++) {
        remendinput(datas[i]);    
    }
    document.close();
      

  3.   

    var datas = ['[email protected]'];function remendinput(oInput) {
        oInput = oInput.replace(/(^|,)(\w+(\.\w+)?)(?!@|\w)/g, "[email protected]");
        //document.getElementById("ss").value = oInput;
        document.write(oInput + '<br/>');
    }document.open();  
    for (var i = 0; i < datas.length; i++) {
        remendinput(datas[i]);    
    }
    document.close();
      

  4.   

    谢谢,非常感谢,搞定了,不过还是一点不明白,如下红色部分(^|,)(\w+(\.\w+)?)(?!@|\w)为什么我写(\w+(\.\w+)*)也没有错误
    写(\w+)也可以,
    为什么要加上(\.\w+)? 呢。