S
Shapper
Hello,
I need to find all emails in a String and replace "@" by AT and the "." by DOT:
1 - "(e-mail address removed)" would become "name AT domain DOT com".
2 - "(e-mail address removed)" would become "name.surname AT domain DOT com"
Note that only the domain dot is replaced. Does this make sense?
At the moment I have the following:
public static String Obfuscate(this String value) {
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 replace = String.Concat("${start}", "AT", "${end}");
return expression.Replace(value, @replace);
}
I am not replacing the dot in this example. How can I do this?
And is there a better way to do this?
I need to find all emails in a String and replace "@" by AT and the "." by DOT:
1 - "(e-mail address removed)" would become "name AT domain DOT com".
2 - "(e-mail address removed)" would become "name.surname AT domain DOT com"
Note that only the domain dot is replaced. Does this make sense?
At the moment I have the following:
public static String Obfuscate(this String value) {
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 replace = String.Concat("${start}", "AT", "${end}");
return expression.Replace(value, @replace);
}
I am not replacing the dot in this example. How can I do this?
And is there a better way to do this?