(1)验证手机号:/^((1[3,5,8][0-9])|(14[5,7])|(17[0,6,7,8]))\d{8}$/
java:
/**
* 验证url
* */
public static boolean chkURL(String str){
try {
if(!str.equals("")||str!=null){
String regex="^((https|http|ftp|rtsp|mms)?:\\/\\/)?([0-9a-z_!~*\'()-]+.)*$";
Pattern p = Pattern.compile(regex);
Matcher m = p.matcher(str);
if(!m.matches()){
return false;
}else return true;
}
} catch (Exception e) {
e.printStackTrace();
}
return false;
}
public static woid main(String[] args) {
if(!chkURL("www.info.com")) {
System.out.println("不匹配");
}
}
js:
function checkUrl(value){
if("" != value) {
var regex = /^((https|http|ftp|rtsp|mms)?:\/\/)?([0-9a-z_!~*\'()-]+.)*$/gi;
var result = regex.test(value);
if(!result) {
return false;
} else {
return true;
}
}
return false;
}
if(!checkUrl("www.bai.com")) {
alert("不匹配");
}