思路:正则表达式。
function isAvailableEmail(sEmail) { //正则表达式模式 let reg=/^[\w\.-]+@[a-zA-Z\d-]+(\.[a-zA-Z\d-]+)*\.[a-zA-Z\d-]+$/ //判断字符串是否满足正则表达式模式 return reg.test(sEmail) }
总结:正则表达式模式使用//分割;模式.test(字符串)用于判断字符串是否满足正则表达式模式。