Java String Sub String substringAfter(String text, String after)

Here you can find the source of substringAfter(String text, String after)

Description

Returns the portion of the overall string that comes after the first occurance of the given string.

License

LGPL

Declaration


public static String substringAfter(String text, String after) 

Method Source Code

//package com.java2s;
// Metawidget (licensed under LGPL)

public class Main {
    /**/*w  w w.  ja va 2  s.  co m*/
     * Returns the portion of the overall string that comes after the first occurance of the given
     * string. If the given string is not found in the overall string, returns the entire string.
     */

    public static String substringAfter(String text, String after) {

        int indexOf = text.indexOf(after);

        if (indexOf == -1) {
            return text;
        }

        return text.substring(indexOf + after.length());
    }
}

Related

  1. substringAfter(String str, String separator)
  2. substringAfter(String string, String delim)
  3. substringAfter(String string, String delimiter)
  4. substringAfter(String template, String toFind, String defaultTo)
  5. substringAfter(String text, int index)
  6. substringAfter(String value, char delim)
  7. substringAfterFirstIndex(String value)
  8. substringAfterIfExist(String source, String rev)
  9. subStringAfterIgnoreCase(String str, String separator, Integer num)