@Nonnull
	public static String cutOffAtNth(@Nonnull String text, char cutoff, int n) {
		int i = -1;
		while (n-- > 0) {
			if ((i = text.indexOf(cutoff, i + 1)) < 0)
				return text;
		}
		if (i < 0) return text;
		return text.substring(0, i);
	}
@Test
	void testCutOffAtNth() {
		// chars
		assertEquals("", StringUtil.cutOffAtNth("", 'a', -1));
		assertEquals("", StringUtil.cutOffAtNth("", 'a', 0));
		assertEquals("", StringUtil.cutOffAtNth("", 'a', 1));
		assertEquals("aaa", StringUtil.cutOffAtNth("aaa", 'a', -1));
		assertEquals("aaa", StringUtil.cutOffAtNth("aaa", 'a', 0));
		assertEquals("", StringUtil.cutOffAtNth("aaa", 'a', 1));
		assertEquals("a", StringUtil.cutOffAtNth("aaa", 'a', 2));
		assertEquals("aa", StringUtil.cutOffAtNth("aaa", 'a', 3));
		assertEquals("aaa", StringUtil.cutOffAtNth("aaa", 'a', 4));
		// strings
		assertEquals("", StringUtil.cutOffAtNth("", "a", -1));
		assertEquals("", StringUtil.cutOffAtNth("", "a", 0));
		assertEquals("", StringUtil.cutOffAtNth("", "a", 1));
		assertEquals("aaa", StringUtil.cutOffAtNth("aaa", "a", -1));
		assertEquals("aaa", StringUtil.cutOffAtNth("aaa", "a", 0));
		assertEquals("", StringUtil.cutOffAtNth("aaa", "a", 1));
		assertEquals("a", StringUtil.cutOffAtNth("aaa", "a", 2));
		assertEquals("aa", StringUtil.cutOffAtNth("aaa", "a", 3));
		assertEquals("aaa", StringUtil.cutOffAtNth("aaa", "a", 4));
		assertEquals("b", StringUtil.cutOffAtNth("bbbbbbbbbb", "bb", 2));
		assertEquals("bb", StringUtil.cutOffAtNth("bbbbbbbbbb", "bb", 3));
		assertEquals("bbb", StringUtil.cutOffAtNth("bbbbbbbbbb", "bb", 4));
	}