如题
String txt= 网页代码
比如txt已经为提取出来的一段网页代码,如何从txt中提取出email地址,听说用正则表达示
我知道邮件的正则表达示为
\w+([-+.]\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*
谁能告诉我怎么操作才能利用这个正则表过示从txt中提取出email地址吗?

解决方案 »

  1.   

    Regex reg = new Regex("\\w+([-+.]\\w+)*@\\w+([-.]\\w+)*\\.\\w+([-.]\\w+)*", RegexOptions.IgnoreCase | RegexOptions.Singleline);
            string html = "网页代码";
            MatchCollection mc = reg.Matches(html);
            foreach (Match m in mc)
            {
                m.Groups[0].Value//Email,作处理吧
            }
      

  2.   

    再问一下楼上的兄弟
    现在调试提示缺少using引用(Regex),请问是引用什么?
    谢谢
      

  3.   

    using System.Text.RegularExpressions