62,616
社区成员
发帖
与我相关
我的任务
分享
public static void main(String[] args) {
String str = "myBean[3].student[1].score[5].value";
Pattern pattern = Pattern.compile("\\[(\\d+)\\]");
Matcher m = pattern.matcher(str);
while(m.find()){
str = str.replace(m.group(), "[" + (Integer.parseInt(m.group(1))+1) + "]");
}
System.out.println(str);
}