List of utility methods to do String Sub String
String | substringAfterLast(String text, char after) Returns the portion of the overall string that comes after the last occurance of the given string. int indexOf = text.lastIndexOf(after); if (indexOf == -1) { return text; return text.substring(indexOf + 1); |
String | subStringAfterLastSymbol(String inStr, char symbol) sub String After Last Symbol return inStr.substring(inStr.lastIndexOf(symbol) + 1);
|
String | substringAfterReturnAll(String str, String before) substring After Return All int pos = str.indexOf(before); if (pos != -1) { return str.substring(pos + before.length()); return str; |
String | substringAndchopLastNewline(String text, int start_pos, int end_pos) Gets text substring from 'start_pos' position till 'end_pos' position and chop last symbol if it is newline \n symbol. if (start_pos < 0 || start_pos >= end_pos || end_pos > text.length() - 1) { return NULL_STRING; if (end_pos > 0 && '\n' == text.charAt(end_pos - 1)) { end_pos--; return text.substring(start_pos, end_pos); |
String[] | subStringArray(String in[], int start, int end) Return a subset of an array. String[] ret = new String[end - start]; int j = 0; for (int i = start; i < end; i++) { ret[j++] = in[i]; return ret; |
String | substringBaseName(String baseName, int extraCharsNumber) substring Base Name baseName = baseName.substring(0, baseName.length() - extraCharsNumber - 3) + "..."; return baseName; |
String | substringBefore(final String str, final String separator) substring Before if (str == null || str.length() == 0) { return str; if (separator == null || str.indexOf(separator) == -1) { return str; return str.substring(0, str.indexOf(separator)); |
String | substringBefore(final String string, final String separator) substring Before if (isEmpty(string) || separator == null) { return string; if (separator.length() == 0) { return ""; final int pos = string.indexOf(separator); if (pos == -1) { ... |
String | substringBefore(String input, String sub) Return the substring before the first occurrence of SUB else INPUT (if substring does not occur). int pos = input.indexOf(sub); if (pos < 0) { return input; return input.substring(0, pos); |
String | substringBefore(String s, char c) substring Before int pos = s.indexOf(c); return pos >= 0 ? s.substring(0, pos) : s; |