public class Tools {
private static String pattern = "^([hH][tT]{2}[pP]://|[hH][tT]{2}[pP][sS]://)(([A-Za-z0-9-~]+).)+([A-Za-z0-9-~\\/])+$";
/**
* 判断 url 是否合法
*/
public static boolean isUrl(String url) {
Pattern httpPattern = Pattern.compile(pattern);
if (httpPattern.matcher(url).matches()) {
return true;
}
return false;
}
}
判断一个url是否合法
最新推荐文章于 2023-12-08 14:29:29 发布