[0-9a-z][a-z0-9\._-]{1,}@[a-z0-9-]{1,}[a-z0-9](\.[a-z]{1,})+
之前在网上找的好多验证邮箱的都不支持验证二级域名的邮箱
js 使用方法
function CheckEmail(email){ if (/^[0-9a-z][a-z0-9\._-]{1,}@[a-z0-9-]{1,}[a-z0-9](\.[a-z]{1,})+$/.test(email) { return true; } return false; }
C# 使用方法
class Program { static void Main(string[] args) { Console.WriteLine(CheckEmail("[email protected]")); Console.WriteLine(CheckEmail("[email protected]")); Console.WriteLine(CheckEmail("[email protected]")); } public static bool CheckEmail(string email) { Regex reg = new Regex(@"[0-9a-z][a-z0-9\._-]{1,}@[a-z0-9-]{1,}[a-z0-9](\.[a-z]{1,})+", RegexOptions.IgnoreCase); if (reg.IsMatch(email)) { return true; } return false; } }
手机号码同理
1[3,4,5,8,7][0-9]{9}
js用法
/^1[3,4,5,8,7][0-9]{9}$/
C#用法
@"1[3,4,5,8,7][0-9]{9}"
时间: 2024-10-03 02:32:36