@Test public void testLchop_01() { assertEquals("01", null, StringUtil.lchop(null, null)); assertEquals("02", "whatever", StringUtil.lchop("whatever", null)); assertEquals("03", "", StringUtil.lchop("whatever", "whatever")); assertEquals("04", "A", StringUtil.lchop("whateverA", "whatever")); assertEquals("05", "AA", StringUtil.lchop("whateverAA", "whatever")); assertEquals("06", "BAA", StringUtil.lchop("BAA", "whatever")); assertEquals("07", "BAA", StringUtil.lchop("BAA", "AA")); assertEquals("08", "whatever", StringUtil.lchop("ABABwhatever", "ABAB")); assertEquals("09", "whatever", StringUtil.lchop("ABCABCwhatever", "ABC")); }
public static String lchop(String string, String word) { if (string == null) { return null; } if (word == null || word.length() == 0 || word.length() > string.length()) { return string; } int i = 0; while (string.regionMatches(i, word, 0, word.length())) i += word.length(); return i == string.length() ? EMPTY : string.substring(i); }
StringUtil { public static String lchop(String string, String word) { if (string == null) { return null; } if (word == null || word.length() == 0 || word.length() > string.length()) { return string; } int i = 0; while (string.regionMatches(i, word, 0, word.length())) i += word.length(); return i == string.length() ? EMPTY : string.substring(i); } }
StringUtil { public static String lchop(String string, String word) { if (string == null) { return null; } if (word == null || word.length() == 0 || word.length() > string.length()) { return string; } int i = 0; while (string.regionMatches(i, word, 0, word.length())) i += word.length(); return i == string.length() ? EMPTY : string.substring(i); }  }
StringUtil { public static String lchop(String string, String word) { if (string == null) { return null; } if (word == null || word.length() == 0 || word.length() > string.length()) { return string; } int i = 0; while (string.regionMatches(i, word, 0, word.length())) i += word.length(); return i == string.length() ? EMPTY : string.substring(i); }  static String substr(String string, int from); static String substr(String string, int from, int length); static String zpad(Object obj, int width, String separator); static String zpad(Object obj, int width); static String lpad(Object obj, int width, String separator); static String pad(Object obj, int width); static String pad(Object obj, int width, char padChar); static String pad(Object obj, int width, char padChar, String separator); static String lpad(Object obj, int width); static String lpad(Object obj, int width, char padChar); static String lpad(Object obj, int width, char padChar, String separator); static String rpad(Object obj, int width, String separator); static String rpad(Object obj, int width); static String rpad(Object obj, int width, char padChar); static String rpad(Object obj, int width, char padChar, String separator); static String substring(String string, int from, int to); static String toString(byte[] bytes); static String lchop(String string, String word); static String rchop(String string, String word); static String[] split(String s, String delim); static String[] split(String s, String delim, int numParts); static String trim(String s, char c); static String ltrim(String s, char c); static String trim(String s, char... chars); static String trim(String s, String chars); static String rtrim(String s, char c); static boolean isTrue(String s); static boolean isTrue(String s, boolean dfault); static String getResourceAsString(String path); static InputStream toInputStream(String s); static InputStream toInputStream(String s, String charset); static String fromInputStream(InputStream is); static String fromInputStream(InputStream is, String charset); static String fromInputStream(InputStream is, String charset, int bufsize); static int toInt(String s); static String emptyIfNull(String str); }
StringUtil { public static String lchop(String string, String word) { if (string == null) { return null; } if (word == null || word.length() == 0 || word.length() > string.length()) { return string; } int i = 0; while (string.regionMatches(i, word, 0, word.length())) i += word.length(); return i == string.length() ? EMPTY : string.substring(i); }  static String substr(String string, int from); static String substr(String string, int from, int length); static String zpad(Object obj, int width, String separator); static String zpad(Object obj, int width); static String lpad(Object obj, int width, String separator); static String pad(Object obj, int width); static String pad(Object obj, int width, char padChar); static String pad(Object obj, int width, char padChar, String separator); static String lpad(Object obj, int width); static String lpad(Object obj, int width, char padChar); static String lpad(Object obj, int width, char padChar, String separator); static String rpad(Object obj, int width, String separator); static String rpad(Object obj, int width); static String rpad(Object obj, int width, char padChar); static String rpad(Object obj, int width, char padChar, String separator); static String substring(String string, int from, int to); static String toString(byte[] bytes); static String lchop(String string, String word); static String rchop(String string, String word); static String[] split(String s, String delim); static String[] split(String s, String delim, int numParts); static String trim(String s, char c); static String ltrim(String s, char c); static String trim(String s, char... chars); static String trim(String s, String chars); static String rtrim(String s, char c); static boolean isTrue(String s); static boolean isTrue(String s, boolean dfault); static String getResourceAsString(String path); static InputStream toInputStream(String s); static InputStream toInputStream(String s, String charset); static String fromInputStream(InputStream is); static String fromInputStream(InputStream is, String charset); static String fromInputStream(InputStream is, String charset, int bufsize); static int toInt(String s); static String emptyIfNull(String str); static final String EMPTY; }