Java Utililty Methods String Last Index Of

List of utility methods to do String Last Index Of

Description

The list of methods to do String Last Index Of are organized into topic(s).

Method

intlastIndexOfLetter(String string)
last Index Of Letter
for (int i = 0; i < string.length(); i++) {
    char character = string.charAt(i);
    if (!Character.isLetter(character) ) {
        return i - 1;
return string.length() - 1;
intlastIndexOfNewline(CharSequence theChars, int aStart)
Returns index of the previous newline (or carriage-return/newline) in given chars starting at given char index.
for (int i = aStart - 1; i >= 0; i--) {
    char c = theChars.charAt(i);
    if (c == '\n')
        return i - 1 >= 0 && theChars.charAt(i - 1) == '\r' ? (i - 1) : i;
    if (c == '\r')
        return i;
return -1;
...
intlastIndexOfNonWhitespace(final String src)
last Index Of Non Whitespace
return lastIndexOfNonWhitespace(src, src.length(), 0);
intlastIndexOfOrdinal(String value, String part, int startIndex, int count, boolean caseSensitive)
Performs an ordinal string comparison.
int valueLen = value.length();
int partLen = part.length();
int endIndex = startIndex - count + 1;
if ((valueLen == 0) && (startIndex == -1 || startIndex == 0))
    if (partLen != 0)
        return -1;
    else
        return 0;
...
intlastIndexOfPathSeparator(String str)
last Index Of Path Separator
if (str == null)
    return -1;
int length = str.length();
for (int i = length - 1; i >= 0; i--) {
    char c = str.charAt(i);
    if (c == '/' || c == '\\') {
        return i;
return -1;
intlastIndexOfSeparator(String path)
This routine returns last index of separator in input param "path", and return it.
return Math.max(path.lastIndexOf("/"), path.lastIndexOf("\\"));
intlastIndexOfUCL(String value)
last Index Of UCL
for (int i = value.length() - 1; i >= 0; i--) {
    if (Character.isUpperCase(value.charAt(i))) {
        return i;
return -1;
intlastIndexOfUnnested(String str, char chr, String openBalance, String closeBalance)
last Index Of Unnested
return lastIndexOfUnnested(str, chr, str.length() - 1, openBalance, closeBalance);
intlastIndexOfWhitespace(String s)
last Index Of Whitespace
for (int i = s.length() - 1; i >= 0; i--)
    if (s.charAt(i) <= ' ')
        return i;
return -1;