code: public static String underscored(final String input) {
          if (input == null || input.length() == 0) {
              return "";
          }
  
          return input.trim().replaceAll("([a-z\\d])([A-Z]+)", "$1_$2").replaceAll("[-\\s]+", "_").toLowerCase();
      }
docs: Changes passed in string to all lower case and adds underscore between words.
  
  @param input The input string
  @return the input string in all lower case with underscores between words