Run Code
|
API
|
Code Wall
|
Misc
|
Feedback
|
Login
|
Theme
|
Privacy
|
Patreon
Testing email address validation
//Title of this code //Rextester.Program.Main is the entry point for your code. Don't change it. using System; using System.Collections.Generic; using System.Linq; using System.Globalization; using System.Text.RegularExpressions; namespace Rextester { public class Program { public static bool IsValidEmail(string strIn) { bool invalid = false; if (String.IsNullOrEmpty(strIn)) return false; // Use IdnMapping class to convert Unicode domain names. strIn = System.Text.RegularExpressions.Regex.Replace(strIn, @"(@)(.+)$", DomainMapper); if (invalid) return false; // Return true if strIn is in valid e-mail format. return System.Text.RegularExpressions.Regex.IsMatch(strIn, @"^(?("")("".+?(?<!\\)""@)|(([0-9a-z]((\.(?!\.))|[-!#\$%&'\*\+/=\?\^`\{\}\|~\w])*)(?<=[0-9a-z])@))" + @"(?(\[)(\[(\d{1,3}\.){3}\d{1,3}\])|(([0-9a-z][-\w]*[0-9a-z]*\.)+[a-z0-9][\-a-z0-9]{0,22}[a-z0-9]))$", System.Text.RegularExpressions.RegexOptions.IgnoreCase); } private static string DomainMapper(Match match) { // IdnMapping class with default property values. IdnMapping idn = new IdnMapping(); string domainName = match.Groups[2].Value; try { domainName = idn.GetAscii(domainName); } catch (ArgumentException ex) { Console.WriteLine("Error occured:"+ex.Message); } catch(Exception ex2) { Console.WriteLine("Error occured:"+ex2.Message); } return match.Groups[1].Value + domainName; } public static void Main(string[] args) { Console.WriteLine(IsValidEmail("jorgelu00_@hotmail.com").ToString()); } } }
run
|
edit
|
history
|
help
0
Unturned_Plugins
MonitorPulse.cs
Testing 004
Fórum ➡ Finding STRONG tags that contain UL tags, using Regex class♦
Fórum ➡ Border of a string S with at least 3 non-overlapping solutions ( yield version ) ♦
Valid Substring
dsdsdsdsd
2 ushort remix to 1 int
Convert from one encoding to another
Delegate Example