题解 | #邮箱字符串判断#
邮箱字符串判断
http://www.nowcoder.com/practice/c72b2b5472704d4a98597cb74b0257a7
使用正则表达式匹配
function isAvailableEmail(sEmail) { var reg = /^[0-9a-zA-Z_.]{1,}@[a-zA-Z0-9_.]{1,}[a-zA-Z0-9]{2,4}$/; // 正解 return reg.test(sEmail); }
邮箱字符串判断
http://www.nowcoder.com/practice/c72b2b5472704d4a98597cb74b0257a7
function isAvailableEmail(sEmail) { var reg = /^[0-9a-zA-Z_.]{1,}@[a-zA-Z0-9_.]{1,}[a-zA-Z0-9]{2,4}$/; // 正解 return reg.test(sEmail); }
相关推荐