Java String Sub String subStringExe(String s, String jmp, String sb, String se)

Here you can find the source of subStringExe(String s, String jmp, String sb, String se)

Description

sub String Exe

License

Open Source License

Declaration

public static String subStringExe(String s, String jmp, String sb, String se) 

Method Source Code

//package com.java2s;

public class Main {

    public static String subStringExe(String s, String jmp, String sb, String se) {
        if (isEmpty(s))
            return "";

        int i = 0;
        if (jmp != null) {
            i = s.indexOf(jmp);//from   ww w  . ja v  a  2  s. c  om
            if ((i >= 0) && (i < s.length()))
                s = s.substring(i + 1);
        }

        i = s.indexOf(sb);
        if ((i >= 0) && (i < s.length()))
            s = s.substring(i);

        if (se.equals(""))
            return s;

        i = s.indexOf(se);
        if ((i >= 0) && (i < s.length()))
            s = s.substring(0, i + 3);

        return s;
    }

    public static boolean isEmpty(String s) {
        return ((s == null) || ("".equals(s)));
    }

    public static String isEmpty(String s, String result) {
        if ((s != null) && (!(s.equals(""))))
            return s;

        return result;
    }

    public static boolean equals(String s1, String s2) {
        if ((isEmpty(s1)) && (isEmpty(s2)))
            return true;
        if ((!(isEmpty(s1))) && (!(isEmpty(s2))))
            return s1.equals(s2);

        return false;
    }
}

Related

  1. substringCompare(String string, int index, char... characters)
  2. substringDelimited(String string, String start, String end, int startingPosition)
  3. substringEL(String str, int index, String defaultValue)
  4. substringEnd(String string, int start, int length)
  5. substringEquals(final String s1, final int fromIndex1, final int toIndex1, final String s2, final int fromIndex2, final int toIndex2)
  6. substringFromMatch(String match, String string)
  7. substringFromMultiValuedFields(int start, int end, String[] fieldValues, int offsetGap, String interFieldJoiner)
  8. substringGuarded(String s, int position, int count)
  9. subStringIgnoreCase(String str, String separator, Integer stratNum, Integer endNum)