class TestStudent {
public static void main(String[] args) {
//创建字符串对象,输入学生信息
String s1 = "x:32:91|l:22:95|w:26:91";
String regex="[a-zA-Z]+:\\d{1,3}:\\d{1,3}(\\.\\d{1,2})?";
String[] s2 = s1.split("\\|");
Student[] s3 = new Student[s2.length];
for(int i = 0; i<s2.length; i++){
String[] temp = s2[i].split(":");
s3[i] =new Student(temp[0],Integer.parseInt(temp[1]),Integer.parseInt(temp[2]));
}
Arrays.sort(s3);
for(Student st :s3){
System.out.println(st);
}}
}
你的这个正则表达式regex并没有在任何地方用到啊
代码中没有使用正则表达式进行识别