首页 新闻 赞助 找找看

抓取邮箱 ,字符转换成邮箱问题

0
悬赏园豆:20 [已关闭问题]

我抓取一个网站的邮箱,如:chaoguo2000@126.com

但源文件是: chaoguo2000@126.com

怎么把这个转换成字符串“chaoguo2000@126.com”呢?

问题补充: 我这是在控制台程序,所以希望能在控制台程序里转换
yuejianjun的主页 yuejianjun | 初学一级 | 园豆:20
提问于:2009-04-28 17:10
< >
分享
其他回答(1)
0

Code

需要引用System.Web.dll

kuhaner | 园豆:190 (初学一级) | 2009-04-29 10:45
0

&#99;  这个其实就是HTML代码里用ASCII代码表示字符的方式

&#99; 代表的就是字符为99的ASCII字符,(char)99 执行后输出的就是c

 

具体实现

 

 

 

using System;

using System.Text.RegularExpressions;



namespace ConsoleApplication1

{

class Program

{

static void Main(string[] args)

{

string email = "&#99;&#104;&#97;&#111;&#103;&#117;&#111;2000&#64;126.&#99;&#111;&#109;";

Console.WriteLine(email);

email
= func(email);

Console.WriteLine(email);

Console.ReadKey();

}



public static string func(string s)

{

Regex re
= new Regex(@"&#(\d{2,});");

MatchEvaluator me
= new MatchEvaluator(ReplaceChr);

return re.Replace(s, me);

}



public static string ReplaceChr(Match m)

{

return ((char)Convert.ToInt32(m.Groups[1].Value)).ToString();

}

}

}

 

 

HuaZai | 园豆:206 (菜鸟二级) | 2009-05-01 19:51
清除回答草稿
   您需要登录以后才能回答,未注册用户请先注册