String regex = "\\((.+?)\\)";//正規表現で指定 String target = "(abc)def(ghi)jkl"; List<String> omaewamoshindeiru = new ArrayList<String>(); Pattern pattern = Pattern.compile(regex); Matcher matcher = pattern.matcher(target); while (matcher.find()) { omaewamoshindeiru.add(matcher.group(1)); } System.out.println( omaewamoshindeiru.get(0) );//abc
0 件のコメント:
コメントを投稿