关于加载网络资源--判断“头”是否为http/https/ftp资源等

正则表达式:

(http|ftp|https):\/\/([\w.]+\/?)\S*

Java代码中的判断如下:

Pattern pattern2 = Pattern.compile("(http|ftp|https):\\/\\/([\\w.]+\\/?)\\S*");
Matcher matcher2 = pattern2.matcher(content);

或者:

(url.startsWith("https://"))||(url.startsWith("http://"))




发布了149 篇原创文章 · 获赞 132 · 访问量 11万+

猜你喜欢

转载自blog.csdn.net/Sailor_luo/article/details/80225494
今日推荐