String (@NotNull String name) { // If the name matches the regular expression "-(\\d+(\\.|$))" then the module name will be derived from the sub-sequence // preceding the hyphen of the first occurrence. Matcher m = Patterns.VERSION.matcher(name); if (m.find()) { name = name.substring(0, m.start()); } // All non-alphanumeric characters ([^A-Za-z0-9]) are replaced with a dot (".") ... name = Patterns.NON_NAME.matcher(name).replaceAll("."); // ... all repeating dots are replaced with one dot ... name = Patterns.DOT_SEQUENCE.matcher(name).replaceAll("."); // ... and all leading and trailing dots are removed. name = StringUtil.trimLeading(StringUtil.trimTrailing(name, '.'), '.'); return name; }