韩顺平老师 B站
习题练习

public static void main(String[] args) {
String content = "wu6426-miao@org.com";
if(content.matches("^[\\w-]+@([a-zA-Z]+\\.)+[a-zA-Z]+$")){
System.out.println("合法");
}else{
System.out.println("不合法");
}
}

public static void main(String[] args) {
String content = "-19";
if(content.matches("^(-)?\\d+(\\.)\\d+$")){
System.out.println("小数");
}else{
System.out.println("整数");
}
}

public static void main(String[] args) {
String content = "http://www.sohu.com:8080/abc/index.htm";
Pattern pattern = Pattern.compile("^([a-z]+)://([a-z.]+[a-z]):(\\d+)(/[a-z]+/)([a-z.]+[a-z])$");
Matcher matcher = pattern.matcher(content);
while(matcher.find()){
System.out.println("协议为:" + matcher.group(1));
System.out.println("域名为:" + matcher.group(2));
System.out.println("端口为:" + matcher.group(3));
System.out.println("文件名为:" + matcher.group(5));
}
}