在一个字符串中用正则表达式取值
如果格式正确取出此E-mail地址

解决方案 »

  1.   

    string yourStr = ......;
    MatchCollection mc = Regex.Matches(yourStr, "[A-Z0-9._%-]+@[A-Z0-9._%-]+\\.[A-Z]{2,4}", RegexOptions.IgnoreCase);
    foreach(Match m in mc)
    {
        m.Value;//e-mail address
    }
      

  2.   

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

  3.   

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