62,612
社区成员
发帖
与我相关
我的任务
分享
String s="round-trip (ms) min/avg/max = 0.956/5/6.752";
String regex="\\d+\\.?\\d*";
Pattern p=Pattern.compile(regex);
Matcher m=p.matcher(s);
while(m.find()){
System.out.println(m.group());
}
public static void main(String[] args) {
String strT = "round-trip (ms) min/avg/max = 0.956/5/6.752";
String[] regex = new String[]{"\\d\\.?\\d*(?=/.*/)","(?<=/)\\d\\.?\\d*(?=/)","\\d\\.?\\d*$"};
Pattern p = null;
Matcher m = null;
for (int i =0;i < 3; i++) {
p = Pattern.compile(regex[i]);
m = p.matcher(strT);
while (m.find()) {
System.out.print(m.group());
}
System.out.println();
}
}