匹配数字、字母、ip等

function checkNum(value){
    var regu =/^[0-9\ ]+$/;   
    var re = new RegExp(regu);   
    if (re.test(value)) {   
      return true;   
    }   
    return false; 
}
// 校验IP
function ipvalidate(ip) {
            var val = /([0-9]{1,3}\.{1}){3}[0-9]{1,3}/;
            var vald = val.exec(ip);
            if (vald == null) {
                return false;
            }
            if (vald != '') {
                if (vald[0] != ip) {
                    return false;
                }
            }
            return true;
        }
http://www.iteye.com/blogs/subjects/StudyNotes

你可能感兴趣的:(JavaScript,正则)