@Test public void testTrip() throws Exception { Assert.assertThat(Texts.trip(",,abc,,", ",").toString(), equalTo("abc")); Assert.assertThat(Texts.trip(",.abc,.", ",").toString(), equalTo(".abc,.")); Assert.assertThat(Texts.trip(",.abc,.", ".").toString(), equalTo(",.abc,")); Assert.assertThat(Texts.trip(",.abc,.", ".,").toString(), equalTo("abc")); Assert.assertThat(Texts.trip("", ",").toString(), equalTo("")); Assert.assertThat(Texts.trip(",,,", ",").toString(), equalTo("")); }
public static String trip(CharSequence s, String chars) { if (s == null) { return ""; } int start = 0; int length = s.length(); while (start < length && chars.contains(s.subSequence(start, start + 1))) { start++; } int end = length; while (end > start && chars.contains(s.subSequence(end - 1, end))) { end--; } return s.subSequence(start, end).toString(); }
Texts { public static String trip(CharSequence s, String chars) { if (s == null) { return ""; } int start = 0; int length = s.length(); while (start < length && chars.contains(s.subSequence(start, start + 1))) { start++; } int end = length; while (end > start && chars.contains(s.subSequence(end - 1, end))) { end--; } return s.subSequence(start, end).toString(); } }
Texts { public static String trip(CharSequence s, String chars) { if (s == null) { return ""; } int start = 0; int length = s.length(); while (start < length && chars.contains(s.subSequence(start, start + 1))) { start++; } int end = length; while (end > start && chars.contains(s.subSequence(end - 1, end))) { end--; } return s.subSequence(start, end).toString(); } private  Texts(); }
Texts { public static String trip(CharSequence s, String chars) { if (s == null) { return ""; } int start = 0; int length = s.length(); while (start < length && chars.contains(s.subSequence(start, start + 1))) { start++; } int end = length; while (end > start && chars.contains(s.subSequence(end - 1, end))) { end--; } return s.subSequence(start, end).toString(); } private  Texts(); static String str(CharSequence s); static String str(Object o, String ifNull); static String strNotEmpty(CharSequence s, String ifEmpty); static Func.Transformer<T, String> strTransformer(final String ifNull); static Func.Transformer<T, CharSequence> textTransformer(final String ifNull); static String trim(CharSequence s); static boolean isTrimmedEmpty(CharSequence s); static int trimmedLength(CharSequence s); static int length(CharSequence s); static String trip(CharSequence s, String chars); static String filledStr(int length, char filledChar); static String initials(String[] words); static String join(CharSequence sep, T[] tokens,
                                  boolean skipNull, Func.Transformer<T, String> transformer); static String join(CharSequence sep, Iterable<T> tokens,
                                  boolean skipNull, Func.Transformer<T, String> transformer); static String base64(String s); static String md5(boolean upperCase, String s); static byte[] md5(byte[]... bytes); static byte[] digest(String algorithm, byte[]... bytes); static String bytesToHexString(byte[] bytes, boolean upperCase); static CharSequence withColor(CharSequence text, int color); }
Texts { public static String trip(CharSequence s, String chars) { if (s == null) { return ""; } int start = 0; int length = s.length(); while (start < length && chars.contains(s.subSequence(start, start + 1))) { start++; } int end = length; while (end > start && chars.contains(s.subSequence(end - 1, end))) { end--; } return s.subSequence(start, end).toString(); } private  Texts(); static String str(CharSequence s); static String str(Object o, String ifNull); static String strNotEmpty(CharSequence s, String ifEmpty); static Func.Transformer<T, String> strTransformer(final String ifNull); static Func.Transformer<T, CharSequence> textTransformer(final String ifNull); static String trim(CharSequence s); static boolean isTrimmedEmpty(CharSequence s); static int trimmedLength(CharSequence s); static int length(CharSequence s); static String trip(CharSequence s, String chars); static String filledStr(int length, char filledChar); static String initials(String[] words); static String join(CharSequence sep, T[] tokens,
                                  boolean skipNull, Func.Transformer<T, String> transformer); static String join(CharSequence sep, Iterable<T> tokens,
                                  boolean skipNull, Func.Transformer<T, String> transformer); static String base64(String s); static String md5(boolean upperCase, String s); static byte[] md5(byte[]... bytes); static byte[] digest(String algorithm, byte[]... bytes); static String bytesToHexString(byte[] bytes, boolean upperCase); static CharSequence withColor(CharSequence text, int color); static final Charset UTF_8; }