var pattern = /^[a-z0-9][a-z0-9-\.]+[a-z0-9]$/;
str = '';
console.log(pattern.test(str));
细节分析:
^[a-z0-9] 是指以字母数字字符开头
[a-z0-9]$是指以字母数字字符结尾
[a-z0-9-\.]+是指 中间字符可以是a-z0-9、-和. 这四种字符任意书写
var pattern = /^[a-z0-9][a-z0-9-\.]+[a-z0-9]$/;
str = '';
console.log(pattern.test(str));
细节分析:
^[a-z0-9] 是指以字母数字字符开头
[a-z0-9]$是指以字母数字字符结尾
[a-z0-9-\.]+是指 中间字符可以是a-z0-9、-和. 这四种字符任意书写