所以我想替换一封普通的电子邮件,例如:"teste123@test.com"
到 "teste123null@test.com"'
直到现在我都有这个:
string expression = @"(([^<>()[]\.,;:s@']+(.[^<>()[]\.,;:s@']+)*)|('.+'))@(([[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;
}
email = emails.Value.Replace("@","<b style='display:none;'>null</b>@");