0
点赞
收藏
分享

微信扫一扫

javascript字符判断方法

芥子书屋 2022-05-03 阅读 44
javascript

目的

function checkHostName(str){
	if ( str.match(/^[a-z0-9\-]*$/) == null) {
		return false;
	} else {
		if (str.match(/^[a-z]/) == null) {
			return false;
		} else {
			if (str.match(/[\-]$/) != null) {
				return false;
			} else {
				return true;
			}
		}	
	}
}
举报

相关推荐

0 条评论