@Test
public void test_reg_http() {
String p = "^(http[s]?://[a-zA-Z0-9]+(\\.[a-zA-Z0-9]+)?(\\:[0-9]+)?)";
Pattern pattern = Pattern.compile(p);
String url = "http://github.com:8080/abc";
System.out.println(pattern.matcher(url).find());
url = "https://github.com:8080/abc";
System.out.println(pattern.matcher(url).find());
url = "http://localhost:8080/abc";
System.out.println(pattern.matcher(url).find());
}
添加回复
请先登陆