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

intlastIndexOfAny(String str, String search, int offset)
last Index Of Any
if (str.equals("") || search.equals("")) {
    return -1;
for (int i = str.length(), strCodepoint; i > 0; i -= Character.charCount(strCodepoint)) {
    strCodepoint = str.codePointBefore(i);
    for (int j = search.length(), searchCodepoint; j > 0; j -= Character.charCount(searchCodepoint)) {
        searchCodepoint = search.codePointBefore(j);
        if (strCodepoint == searchCodepoint) {
...
intlastIndexOfAnyBut(String srcString, String validString)
last Index Of Any But
int result = -1;
int srcLen = srcString.length();
for (int i = srcLen - 1; i >= 0; i--) {
    if (validString.indexOf(srcString.charAt(i)) == -1) {
        result = i;
        break;
return result;
intlastIndexOfAnyDelimiter(String str, int fromIndex, String delimiters)
Overloaded method.
if (!hasLength(str)) {
    return -1;
return lastIndexOfAnyDelimiter(str, fromIndex, str.length(), delimiters);
intlastIndexOfIgnoreCase(String pString, String pLookFor)
Returns the index within this string of the rightmost occurrence of the specified substring.
return lastIndexOfIgnoreCase(pString, pLookFor, pString != null ? pString.length() - 1 : -1);
intlastIndexOfIgnoreCase(String s, String substr)
Finds last index of a substring in the given source string with ignored case.
return lastIndexOfIgnoreCase(s, substr, s.length(), 0);
intlastIndexOfIgnoreCase(String source, String str, int fromIndex)
Returns the index within this string of the last occurrence of the specified string.
int count = source.length();
int strCount = str.length();
int rightIndex = count - strCount;
if (fromIndex < 0) {
    return -1;
if (fromIndex > rightIndex) {
    fromIndex = rightIndex;
...
intlastIndexOfIgnoreCase(String str, String searchStr)
Return last sub-String position ignore case, return -1 if not found
if (searchStr.isEmpty() || str.isEmpty())
    return -1;
return str.toLowerCase().lastIndexOf(searchStr.toLowerCase());
intlastIndexOfIgnoreCase(String str, String searchStr)

Case in-sensitive find of the last index within a String.

A null String will return -1.

if (str == null || searchStr == null) {
    return -1;
return lastIndexOfIgnoreCase(str, searchStr, str.length());
intlastIndexOfIgnoreCase(String str, String searchStr, int startPos)
last Index Of Ignore Case
for (int i = startPos; i >= 0; i--) {
    if (str.regionMatches(true, i, searchStr, 0, searchStr.length())) {
        return i;
return -1;
intlastIndexOfImpl(final String str, final String search, final int fromIndex, final boolean ignoreCase)
Searchs the index of the last occurrence of a substring in a string.
final int searchLen = search.length();
for (int i = fromIndex; i >= 0; --i) {
    if (str.regionMatches(ignoreCase, i, search, 0, searchLen)) {
        return i;
return -1;