要求「a~z, A~Z, 0~9」
     「_」
     「-」
      「.」
有且只有一个「@」要求正则表达式能够写在配置文件web.config里不胜感激

解决方案 »

  1.   

    http://bbs.chinaunix.net/viewthread.php?tid=714652
    http://www.code168.com/ShowArticle.asp?ArtClass=5&ArtID=5297
      

  2.   

    如果是这要求,.net自带的稍改下就行了\w+([-.]\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*
      

  3.   

    \w+([-+.']\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*
      

  4.   

    \w+([-.]\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*\w+([-+.']\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*
    我测试下 怎么都不行?
      

  5.   

    string mail = "1#[email protected]"; 
    string pattern = @"\w+([-.]\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*"
    if (!Regex.IsMatch(mail , pattern))
    {
       return false
    }
    return true;结果return true了
      

  6.   

    介个,-_-#...^\w+([-.]\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*$
    string mail = "1#[email protected]"; 
    string pattern = @"^\w+([-.]\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*$";
    if (!Regex.IsMatch(mail , pattern))
    {
       return false;
    }
    return true;
      

  7.   

    ^\w+([-.]\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*$
    这个对了