List<String> (@Nullable String s) { // Version parsing from pkg_resources ensures that all the "pre", "alpha", "rc", etc. are sorted correctly if (s == null) { return Collections.emptyList(); } final Pattern COMPONENT_RE = Pattern.compile("\\d+|[a-z]+|\\.|-|.+"); final List<String> results = new ArrayList<>(); final Matcher matcher = COMPONENT_RE.matcher(s); while (matcher.find()) { final String component = replace(matcher.group()); if (component == null) { continue; } results.add(component); } for (int i = results.size() - 1; i > 0; i--) { if ("00000000".equals(results.get(i))) { results.remove(i); } else { break; } } results.add("*final"); return results; }