//定义正则表达式
String regEx="[0-9 -]"
String oldString= "原字符串";
String newString = str.replaceAll(regEX,替换值);
//不想保留原来的字符串可以直接写成 “str = str.replaceAll(regEX,替换值);”
List<String> list=Arrays.asList("1-cqs,1-hong,2-jiction,2-richard");
list.forEach(s->{
String s1=s.replaceAll(regEx,"");
System.out.println(s1);
})
结果:cqs,jition,hello,jack