所以我想,以取代例如正常的电子邮件:"[email protected]"
到 “teste123 < B风格=‘显示:无;’ >空</B> @ test.com“`取代电子邮件串
到现在为止我已经得到了这一点:在`@`
string expression = @"(([^<>()\[\]\\.,;:\[email protected]']+(\.[^<>()\[\]\\.,;:\[email protected]']+)*)|('.+'))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))";
Regex rx = new Regex(expression);
MatchCollection matches = rx.Matches(conteudo.PaginaConteudo);
Console.WriteLine("{0} matches found in:\n {1}",
matches.Count,
conteudo.PaginaConteudo);
string email,
replacement = "<h5 style='display:none;'>null</h5>",
mailenc,
correctString;
foreach (Match emails in matches)
{
email = emails.Value;
mailenc = "<h5>"+email + replacement+"</h5>";
correctString = conteudoOriginal.PaginaConteudo.Replace(email, mailenc);
conteudoOriginal.PaginaConteudo = correctString;
}
拆分并添加字符串或使用https:// MSDN。 microsoft.com/en-us/library/system.net.mail.mailaddress.aspx并添加您的字符串。 –
这段代码有什么问题?什么是预期的输出?您想在代码中替换哪封电子邮件? –
你不应该在C#中将html代码写成字符串。你在代码中做“UI的样式”,这是令人担忧的可怕分离。为此使用CSS。你还编写了一半代码所缺少的情况,您正在使用有一个正则表达式,我们不能看到它:( –