Use this regex
/^_?[a-zA-Z0-9]([a-zA-Z0-9]*[._+-])*[a-zA-Z0-9_]+@(?!-)[A-Za-z0-9-]{1,63}(?<!-)(\.(?!-)[A-Za-z0-9-]{1,63}(?<!-))*\.[A-Za-z]{2,}$/
Works like examples shows below:
Pranav Kulkarni's Blog
Monday, January 19, 2026
Regex Email validation in c# dot net core
Monday, March 10, 2025
Regex obfuscate email
Use this code in C# to obfuscate email using regex
// Online C# Editor for free
// Write, Edit and Run your C# code using C# Online Compiler
using System;
using System.Text.RegularExpressions;
public class HelloWorld
{
public static void Main(string[] args)
{
Console.WriteLine ("Try programiz.pro");
string _PATTERN = @"(?<=.{4}).(?=[^@]*?@)|(?:(?<=@.)|(?!^)\G(?=[^@]*$))(.)(?=.*\.)[a-zA-Z0-9]";
string s = "john.travolta12+-3878787@gmail.com";
string replacement = "*";
if (!s.Contains("@"))
Console.WriteLine( new String('*', s.Length));
if (s.Split('@')[0].Length < 4)
Console.WriteLine( @"*@*.*");
string result = Regex.Replace(s, _PATTERN, replacement);
Console.WriteLine(result);
}
}
Monday, September 9, 2024
c# httpclient The remote certificate is invalid according to the validation procedure: RemoteCertificateNameMismatch
If we get this error while trying to get http reponse using HttpClient object, it could mean that certificate validation fails for the remote server. In this case we could get around the issue by overriding certification validation logic like so:
var handler = new HttpClientHandler
{
ClientCertificateOptions = ClientCertificateOption.Manual,
ServerCertificateCustomValidationCallback = (httpRequestMessage, cert,
cetChain, policyErrors) => true
};
handler.AllowAutoRedirect =
false;
handler.ServerCertificateCustomValidationCallback
= (cert, chain, erros, flag)=> { return true; };
var apiClient = new HttpClient(handler);
apiClient.SetBearerToken(tokenResponse.AccessToken);
var response =
apiClient.GetAsync(apiUrl).Result;
Wednesday, April 24, 2024
SSL Error - The connection for this site is not secure
After cloning a git repo of dot net framework website and trying to run it all I could see was this error
Monday, March 25, 2024
C# generic type converter
Here is a way to create a generic type converter in c#
c# - How to Convert a String to a Nullable Type Which is Determined at Runtime? - Stack Overflow
Share cookies between dot net framework and dot net core
c# - share authentication cookie between .NET Framework and .Net Core - Stack Overflow
Regex Email validation in c# dot net core
Use this regex /^_?[a-zA-Z0-9]([a-zA-Z0-9]*[._+-])*[a-zA-Z0-9_]+@(?!-)[A-Za-z0-9-]{1,63}(?<!-)(\.(?!-)[A-Za-z0-9-]{1,63}(?<!-))*\.[A-...
-
If we get this error while trying to get http reponse using HttpClient object, it could mean that certificate validation fails for the remo...
-
While querying for events in a list which fall under a specified time period, the infopath form works correctly in client side editor, but ...
-
SharePoint has a great feature to set terms which can be used to tag contents and enable terms based navigation and several other interesti...