private static int versionCompare(final String current, final String remote) {
    final String[] curComp = current.trim().split("\\.|-|\\s+");
    final String[] remComp = remote.trim().split("\\.|-|\\s+");
    int result = 0;
    for (int i = 0; (result == 0) && (i < Math.min(curComp.length, remComp.length)); i++) {
      try {
        // Try numerical comparison first
        result = Integer.parseInt(curComp[i]) - Integer.parseInt(remComp[i]);
      } catch (final NumberFormatException e) {
        // Fall back to lexical comparison (for version components like "beta")
        result = curComp[i].compareToIgnoreCase(remComp[i]);
      }
    }

    // Clamp result to -1, 0 and 1 respectively
    return result < -1 ? -1 : (result > 1 ? 1 : result);
  }
Compares two version strings component-wise. Use to compare componentized version strings like
"3.2.2 beta 1" and "10.1". Both strings are split using the regular expression "\\.|-|\\s+".

@param current the source version string
@param remote the target version string to compare against
@return -1, 0 or 1 as the specified current version string is less than, equal to or greater
    than the specified target version string
java/zylib/src/main/java/com/google/security/zynamics/zylib/gui/license/UpdateCheckHelper.java