code: public static String before(String text, String before) {
          if (!text.contains(before)) {
              return null;
          }
          return text.substring(0, text.indexOf(before));
      }
docs: Returns the string before the given token
  
  @param text  the text
  @param before the token
  @return the text before the token, or <tt>null</tt> if text does not contain the token