Existing demand
form filling domain only fill baseURL or baseURL + port without the agreement
otherwise unlawful
String url1 = ".com:90";
String url2 = "w.xx.com.cn:9900990w";
String url3 = "http://w.xx.com";
String url4 = "ww.ww";
String url5 = "www.com.com:9999";
Pattern pattern = Pattern .compile("^(([A-Za-z0-9-~]+)\.)+([A-Za-z0-9-~\/]+|[A-Za-z0-9-~\/]+[:]{1}[\d]+)$");
System.out.println(pattern.matcher(url1).matches());
System.out.println(pattern.matcher(url2).matches());
System.out.println(pattern.matcher(url3).matches());
System.out.println(pattern.matcher(url4).matches());
System.out.println(pattern.matcher(url5).matches());
Operating results:
false
false
false
to true
to true