今天给各位分享java正则表达式提取url的知识,其中也会对java正则表达式提取字符串进行解释,如果能碰巧解决你现在面临的问题,别忘了关注本站,现在开始吧!
本文目录一览:
1、java 提取字符串中包含所有的url, 正则表达式怎么写2、java正则表达式截取URL3、Java中如何用正则表达式解析页面,提取所有URL
java 提取字符串中包含所有的url, 正则表达式怎么写
import java.net.URL;
public class MainClass {
public static void main(String[] args) {
String host = “”;
String file = “/index.html”;
String[] schemes = {“http”, “https”, “ftp”, “mailto”, “telnet”, “file”, “ldap”, “gopher”,
“jdbc”, “rmi”, “jndi”, “jar”, “doc”, “netdoc”, “nfs”, “verbatim”, “finger”, “daytime”,
“systemresource”};
for (int i = 0; i schemes.length; i++) {
try {
URL u = new URL(schemes[i], host, file);
System.out.println(schemes[i] + ” is supported\r\n”);
} catch (Exception ex) {
System.out.println(schemes[i] + ” is not supported\r\n”);
}
}
}
}
java正则表达式截取URL
String reg = “.*\\/\\/([^\\/\\:]*).*”;
String str1 = ” “;
System.out.println (str1.replaceAll (reg, “$1”));
String str2 = “”;
System.out.println (str2.replaceAll (reg, “$1”));
Java中如何用正则表达式解析页面,提取所有URL
先用正则表达式把所有的url找出来string reg = @”(?is)a[^]*href=([‘””]?)(?url[^'””\s]+)[^]*”;然后再替换掉你想要的
java正则表达式提取url的介绍就聊到这里吧,感谢你花时间阅读本站内容,更多关于java正则表达式提取字符串、java正则表达式提取url的信息别忘了在本站进行查找喔。