正则表达式集锦

var regIP = /^((2[0-4][0-9]|25[0-5]|[01]?[0-9][0-9]?).){3}(2[0-4][0-9]|25[0-5]|[01]?[0-9][0-9]?)$/;   //ip正则表达式
var regPath = /^[a-zA-Z]:\([^\?/*|<>:"]+\)*$/;   //文件夹路径正则表达式
var ipStr="123.12.1.1";
var pathStr="C:abc";
if(!regIP.exec(ipStr)){		
  alert("IP不合法");
}
	 
if(!regPath.exec(pathStr)){
  alert("路径不合法");
}

  

原文地址:https://www.cnblogs.com/bright-lin/p/4256466.html