public static void main(String[] args) {
String str = "hTTP://127.0.0.1:3000/abc/test.php";
//转换为小写
// str = str.toLowerCase();
String regex ="^([hH][tT]{2}[pP]://|[hH][tT]{2}[pP][sS]://)(([A-Za-z0-9-~]+).)+([A-Za-z0-9-~\\\\\\\\/])+$";
boolean matches = str.matches(regex);
System.out.println(matches);
}
注意: 亲测 该正则不区分http和https的大小写问题, 例如 hTTP或hTtp 等 都显示true