Java String Sub String substringAfterLast(String string, String delimiter)

Here you can find the source of substringAfterLast(String string, String delimiter)

Description

Returns the substring after the last delimiter of the specified occurrence.

License

Apache License

Declaration

public static String substringAfterLast(String string, String delimiter) 

Method Source Code

//package com.java2s;
//License from project: Apache License 

public class Main {
    /**//w  ww .j  a v a  2 s .co  m
     * Returns the substring after the last delimiter of the specified
     * occurrence. The delimiter is not part of the result.
     */
    public static String substringAfterLast(String string, String delimiter) {
        final int index = string.lastIndexOf(delimiter);
        if (index == -1 || string.endsWith(delimiter)) {
            return "";
        }
        return string.substring(index + 1);
    }
}

Related

  1. substringAfterLast(final String value, final String searchValue)
  2. substringAfterLast(String input, String delimiter)
  3. substringAfterLast(String str, String pattern)
  4. substringAfterLast(String str, String separator)
  5. substringAfterLast(String str, String separator)
  6. substringAfterLast(String text, char after)
  7. subStringAfterLastSymbol(String inStr, char symbol)
  8. substringAfterReturnAll(String str, String before)
  9. substringAndchopLastNewline(String text, int start_pos, int end_pos)