Java Utililty Methods String Sub String

List of utility methods to do String Sub String

Description

The list of methods to do String Sub String are organized into topic(s).

Method

StringsubstringAfterIfExist(String source, String rev)
substring After If Exist
if (source == null)
    return source;
int n = source.indexOf(rev);
if (n == -1)
    return source;
return source.substring(n + rev.length());
StringsubStringAfterIgnoreCase(String str, String separator, Integer num)
sub String After Ignore Case
return subStringAfter(str, separator, num, true);
StringsubstringAfterLast(final String str, final String separator)

Gets the substring after the last occurrence of a separator.

if (isEmpty(str)) {
    return str;
if (isEmpty(separator)) {
    return "";
final int pos = str.lastIndexOf(separator);
if (pos == -1 || pos == str.length() - separator.length()) {
...
StringsubstringAfterLast(final String str, final String separator)
substring After Last
if (str == null) {
    return null;
final int pos = str.lastIndexOf(separator);
if (pos == -1 || pos == (str.length() - separator.length())) {
    return "";
return str.substring(pos + separator.length());
...
StringsubstringAfterLast(final String value, final String searchValue)
substring After Last
final int index = value.lastIndexOf(searchValue);
return (index < 0 || index >= value.length()) ? value : value.substring(index + 1);
StringsubstringAfterLast(String input, String delimiter)
substring After Last
final int lastIndexOfDelimiter = input.lastIndexOf(delimiter);
if (lastIndexOfDelimiter <= 0)
    return input;
return input.substring(lastIndexOfDelimiter + 1);
StringsubstringAfterLast(String str, String pattern)
substring After Last
return str.substring(str.lastIndexOf(pattern) + 1);
StringsubstringAfterLast(String str, String separator)
substring After Last
if (isEmpty(str)) {
    return str;
if (isEmpty(separator)) {
    return "";
int pos = str.lastIndexOf(separator);
if ((pos == -1) || (pos == str.length() - separator.length())) {
...
StringsubstringAfterLast(String str, String separator)

Gets the substring after the last occurrence of a separator.

if (isEmpty(str)) {
    return str;
if (isEmpty(separator)) {
    return EMPTY;
int pos = str.lastIndexOf(separator);
if (pos == INDEX_NOT_FOUND || pos == (str.length() - separator.length())) {
...
StringsubstringAfterLast(String string, String delimiter)
Returns the substring after the last delimiter of the specified occurrence.
final int index = string.lastIndexOf(delimiter);
if (index == -1 || string.endsWith(delimiter)) {
    return "";
return string.substring(index + 1);