public static VersionNumber parse(String versionString) {
    if (versionString == null) return UNKNOWN;
    Matcher m = versionPattern.matcher(versionString);
    if (!m.matches()) return UNKNOWN;

    int major = Integer.parseInt(m.group("major"));
    String minorString = m.group("minor");
    int minor = minorString == null ? 0 : Integer.parseInt(minorString);
    String microString = m.group("micro");
    int micro = microString == null ? 0 : Integer.parseInt(microString);
    String qualifier = m.group("qualifier");
    boolean isSnapshot = m.group("snapshot") != null;
    int versionFields = 1;
    if (minorString != null) {
      versionFields++;
      if (microString != null) {
        versionFields++;
      }
    }

    return new VersionNumber(major, minor, micro, isSnapshot, qualifier, versionFields);
  }
A version number with format major.minor.micro-qualifier.
spock-core/src/main/java/org/spockframework/util/VersionNumber.java