List of utility methods to do String Sub String
String | substringDelimited(String string, String start, String end, int startingPosition) substring Delimited int startIndex = string.indexOf(start, startingPosition); if (startIndex == -1) { return null; startIndex += start.length(); int endIndex = string.indexOf(end, startIndex); if ((startIndex < endIndex) && (endIndex != -1) && (startIndex != -1)) { return string.substring(startIndex, endIndex); ... |
String | substringEL(String str, int index, String defaultValue) substring EL if (str == null || index < 0 || index > str.length()) return defaultValue; return str.substring(index); |
String | substringEnd(String string, int start, int length) Substrings the string using start index and length, that defines the number of characters in the substringed string. return string.substring(start,
Math.max(start, string.length() - Math.min(start + length, string.length())));
|
boolean | substringEquals(final String s1, final int fromIndex1, final int toIndex1, final String s2, final int fromIndex2, final int toIndex2) Check equality of two substrings. if (toIndex1 < fromIndex1) { throw new IndexOutOfBoundsException(); if (toIndex2 < fromIndex2) { throw new IndexOutOfBoundsException(); final int len1 = toIndex1 - fromIndex1; final int len2 = toIndex2 - fromIndex2; ... |
String | subStringExe(String s, String jmp, String sb, String se) sub String Exe if (isEmpty(s)) return ""; int i = 0; if (jmp != null) { i = s.indexOf(jmp); if ((i >= 0) && (i < s.length())) s = s.substring(i + 1); i = s.indexOf(sb); if ((i >= 0) && (i < s.length())) s = s.substring(i); if (se.equals("")) return s; i = s.indexOf(se); if ((i >= 0) && (i < s.length())) s = s.substring(0, i + 3); return s; |
String | substringFromMatch(String match, String string) substring From Match int indexOf = string.indexOf(match); return indexOf == -1 ? "" : string.substring(indexOf); |
String | substringFromMultiValuedFields(int start, int end, String[] fieldValues, int offsetGap, String interFieldJoiner) This calculates a substring from an array of StorableFields. start = (start < 0) ? 0 : start; end = (end < 0) ? 0 : end; if (start > end) { start = end; int charBase = 0; StringBuilder sb = new StringBuilder(); int lastFieldIndex = 0; ... |
String | substringGuarded(String s, int position, int count) Like String#substring(int) but allows for the count parameter to extend past the string's bounds. int sLength = s.length(); if (sLength - position <= count) { return position == 0 ? s : s.substring(position); } else { return s.substring(position, position + count); |
String | subStringIgnoreCase(String str, String separator, Integer stratNum, Integer endNum) sub String Ignore Case return subString(str, separator, stratNum, endNum, true);
|
String | substringInBetween(String name, String prefix, String delimiter) substring In Between int startPos = 0; if (prefix != null) startPos = prefix.length() + 1; int endPos = name.indexOf(delimiter, startPos); if (endPos > 0) return name.substring(startPos, endPos); return null; |