String formula = "【1】【2】【3】";
String regex = "【([^】]*)】";
Pattern pattern = Pattern. compile(regex);
Matcher matchar = pattern.matcher(formula);
while (matchar.find()) {
System.out.println(matchar.group(1));
}
String content = "good[hello]123";
String regex="(?<=\\[)(\\S+)(?=\\])"; //匹配方括号
//String regex = "(?<=\\()[^\\)]+"; //匹配圆括号
Pattern p = Pattern.compile(regex);
Matcher matcher = p.matcher(content);
while (matcher.find()) {
System.out.println(matcher.group());
}