code: public String substringBefore(String string, String pattern) {
  		if (string == null || pattern == null) {
  			return string;
  		}
  		int pos = string.indexOf(pattern);
  		if (pos != -1) {
  			return string.substring(0, pos);
  		}
  		return null;
  	}
docs: Gets the substring before a given pattern
  
  @param string
  original string
  @param pattern
  pattern to check
  @return substring before the pattern