??? 如何获取网页中的email
我现在获取了网页代码,我想把这个页面所有的email提取出来
有好的办法么?
------解决方案--------------------static string[] getMailAddress(string source)
{
string p = @ "\w+([-+. ']\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)* ";
System.Text.RegularExpressions.Regex reg = new Regex(p);
System.Text.RegularExpressions.MatchCollection mc = reg.Matches(source);
string[] result=new string[mc.Count];
for (int i = 0; i < result.Length; i++)
{
result[i] = mc[i].Value;
}
return result;
}
static void Main(string[] args)
{
string source = "a@b.net <b> 或者 </b> b@c.net ";
string[] s = getMailAddress(source);
for (int i = 0; i < s.Length;i++ )
{
Console.WriteLine(s[i]);
}
}