/** * Returns the largest substring of the given string that * does not have an integer at the end. * @param s the source string * @return the stripped string */ private static String stripIntegerEndingFrom(String s) { return recursiveStripIntegerEndingFrom(s); }
/** * Returns the largest substring of the given string that * does not have an integer at the end. * @param s the source string * @return the stripped string */ private static String recursiveStripIntegerEndingFrom(String s) { if (s.length() > 1) { String shorterByOne = s.substring(0, s.length() - 1); String lastBit = s.substring(s.length() - 1, s.length()); try { Integer.parseInt(lastBit); return recursiveStripIntegerEndingFrom(shorterByOne); } catch (NumberFormatException nfe) { return s; } } return s; }