S
shapper
Hello,
I need to obfuscate all emails in a string. e.g:
To replace an email "(e-mail address removed)" by "name(at)domain(dot).com".
I have been using the following but it only replaces @ and I am not
sure if this is the best way to do this:
public static String Obfuscate(String text, String at) {
Regex expression = new Regex(@"\b(?<start>[a-z0-9!#$%&'*+/=?^_`
{|}~-]+(?:\.[a-z0-9!#$%&'*+/=?^_`{|}~-]+)*)@(?<end>(?:[a-z0-9](?:[a-
z0-9-]*[a-z0-9])?\.)+(?:[A-Z]{2}|com|org|net|gov|mil|biz|info|mobi|
name|aero|jobs|museum))\b", RegexOptions.IgnoreCase);
String fix = String.Concat("${start}", at, "${end}");
return text == null ? null : expression.Replace(text, @fix);
} // Obfuscate
I would like to be able to use replace the DOT to and maybe not using
a regex would be better?
Thanks,
Miguel
I need to obfuscate all emails in a string. e.g:
To replace an email "(e-mail address removed)" by "name(at)domain(dot).com".
I have been using the following but it only replaces @ and I am not
sure if this is the best way to do this:
public static String Obfuscate(String text, String at) {
Regex expression = new Regex(@"\b(?<start>[a-z0-9!#$%&'*+/=?^_`
{|}~-]+(?:\.[a-z0-9!#$%&'*+/=?^_`{|}~-]+)*)@(?<end>(?:[a-z0-9](?:[a-
z0-9-]*[a-z0-9])?\.)+(?:[A-Z]{2}|com|org|net|gov|mil|biz|info|mobi|
name|aero|jobs|museum))\b", RegexOptions.IgnoreCase);
String fix = String.Concat("${start}", at, "${end}");
return text == null ? null : expression.Replace(text, @fix);
} // Obfuscate
I would like to be able to use replace the DOT to and maybe not using
a regex would be better?
Thanks,
Miguel