Java String Sub String subString4lastIndex(String string, String regex)

Here you can find the source of subString4lastIndex(String string, String regex)

Description

sub Stringlast Index

License

Open Source License

Declaration

public static String subString4lastIndex(String string, String regex) 

Method Source Code

//package com.java2s;
//License from project: Open Source License 

public class Main {

    public static String subString4lastIndex(String string, String regex) {
        if (isNullOrEmpty(string) || isNullOrEmpty(regex)) {
            return string;
        }/*from   ww  w  .j  a va  2 s .c o m*/
        if (string.indexOf(regex) == -1) {
            return string;
        }
        return string.substring(string.lastIndexOf(regex) + regex.length());
    }

    public static boolean isNullOrEmpty(String s) {
        return s == null || s.length() == 0;
    }

    public static boolean isNullOrEmpty(String... ss) {
        for (String s : ss) {
            if (s == null || s.length() == 0) {
                return true;
            }
        }
        return false;
    }
}

Related

  1. subString(String text, String leadingPart)
  2. subString(String val, int start, int end)
  3. SubString(String x, long y)
  4. substring(StringBuffer buf, int start, int lim)
  5. substring2ByteString(String str, int endIndex)
  6. substringAfter(final String str, final String separator)
  7. substringAfter(String s, String cs)
  8. substringAfter(String s, String substr, boolean fromend)
  9. substringAfter(String sourceStr, String expr)