StrUtils { public static LinkedList<String> splitMulti(String origin, final String... separators) { int len; if (StrUtils.isEmpty(origin) || separators == null || (len = separators.length) == 0) return null; int index; LinkedList<String> result = new LinkedList<>(); for (int i = 0; i < separators.length; i++) { if ((index = origin.indexOf(separators[i])) == -1) break; origin = origin.substring(index + separators[i].length()); if (i == len - 1) { result.add(origin); break; } index = origin.indexOf(separators[i + 1]); if (index == -1) break; result.add(origin.substring(0, index)); origin = origin.substring(index); } return result; } private  StrUtils(); static String fillWithZero(Number aim, int num); static String getMainValue(String suppressCode, int headIndex, String needRemoved); static boolean isEmpty(final String s); static boolean isNotEmpty(final String s); static boolean isBlank(String s); static boolean isNotBlank(String s); static String cutStartStr(String origin, String start); static String cutMiddleStr(String origin, String middle); static String cutTailStr(String origin, String tail); static LinkedList<String> splitMulti(String origin, final String... separators); static boolean isLike(final String origin, final String aim, final String... ignores); static boolean isNumber(final String s); static String str2Hex(String s); static String hex2Str(String s); static String compression(String s); static final String ZERO; static final String HEX; static final String COLON; static final String COMMA; static final String DOUBLE_TRANSFER; static final String PLUS; static final String MINUS; static final char POINT; static final String NEXT_LINE; }
@Test public void splitMultiTest() { LinkedList<String> expect = new LinkedList<>(); expect.add("ns_fac"); expect.add("hb_scapaysettlereg_acc"); expect.add("006b897c8c6b0cdc258566b81508efe5"); expect.add("storeCount"); LinkedList<String> result = splitMulti( "namespace_ns_fac_table_hb_scapaysettlereg_acc_region_006b897c8c6b0cdc258566b81508efe5_metric_storeCount", "namespace_", "_table_", "_region_", "_metric_"); assert result != null; int size = result.size(); assertEquals(expect.size(), size); for (int i = 0; i < size; i++) { assertEquals(expect.get(i), result.get(i)); } }