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

intlastIndexOf(final CharSequence cs, final int searchChar, int start)
Returns the index within cs of the last occurrence of the specified character, searching backward starting at the specified index.
if (cs instanceof String) {
    return ((String) cs).lastIndexOf(searchChar, start);
final int sz = cs.length();
if (start < 0) {
    return NOT_FOUND;
if (start >= sz) {
...
intlastIndexOf(final String input, final char delim)
Gets the last index of a character ignoring characters that have been escaped
return input == null ? -1 : lastIndexOf(input, delim, input.length());
intlastIndexOf(final String src, final String sub, int startIndex, int endIndex)
last Index Of
final int sublen = sub.length();
final int srclen = src.length();
if (sublen == 0) {
    return (startIndex > srclen) ? srclen : ((startIndex < -1) ? -1 : startIndex);
final int total = srclen - sublen;
if (total < 0) {
    return -1;
...
intlastIndexOf(String baseString, String indexString)
last Index Of
if (baseString == null)
    return -1;
else
    return baseString.lastIndexOf(indexString);
intlastIndexOf(String input, char ch, int offset)
Like a String.lastIndexOf but without MIN_SUPPLEMENTARY_CODE_POINT handling
for (int i = input.length() - 1 - offset; i >= 0; i--) {
    if (input.charAt(i) == ch) {
        return i;
return -1;
intlastIndexOf(String path, char ch)
last Index Of
if (path == null) {
    return -1;
return path.lastIndexOf(ch);
intlastIndexOf(String s, String sub, int startIndex, int endIndex)
Finds last index of a substring in the given source string in specified range [end, start] See #indexOf(String,String,int,int) for details about the speed.
int sublen = sub.length();
int srclen = s.length();
if (sublen == 0) {
    return startIndex > srclen ? srclen : (startIndex < -1 ? -1 : startIndex);
int total = srclen - sublen;
if (total < 0) {
    return -1;
...
IntegerlastIndexOf(String self, String pattern, Integer start)
last Index Of
return self.lastIndexOf(pattern, start);
intlastIndexOf(String str, char searchChar)
last Index Of
if ((str == null) || (str.length() == 0)) {
    return -1;
return str.lastIndexOf(searchChar);
intlastIndexOf(String str, char searchChar)

Finds the last index within a String, handling null.

if (isEmpty(str)) {
    return -1;
return str.lastIndexOf(searchChar);