List<String> (@NotNull String s, @NotNull Pattern pattern, int groupIndex) { List<String> result = new SmartList<>(); Matcher m = pattern.matcher(s); while (m.find()) { String group = m.group(groupIndex); if (group != null) { result.add(group); } } return result; }