public static CharSequence withoutSubSequence(CharSequence input, int beginIndex, int endIndex) {
    if (input == null) throw new NullPointerException("input == null");
    int length = input.length();

    // Exit early if the region is empty or the entire input
    int skippedRegionLength = regionLength(length, beginIndex, endIndex);
    if (skippedRegionLength == 0) return input;
    if (beginIndex == 0 && endIndex == length) return "";

    // Exit early if the region ends on a boundary.
    // This doesn't use input.subsequence as it might allocate a String
    if (beginIndex == 0) return new SubSequence(input, endIndex, length);
    if (endIndex == length) return new SubSequence(input, 0, beginIndex);

    // Otherwise, the region to skip in the middle
    return new WithoutSubSequence(input, 0, beginIndex, endIndex, length);
  }
@Test void withoutSubSequence() {
    String input = "b3=1,es=2";
    assertThat(CharSequences.withoutSubSequence(input, 0, 0))
      .isSameAs(input);
    assertThat(CharSequences.withoutSubSequence(input, 0, input.length()))
      .isInstanceOf(String.class).isEmpty();

    assertThat(CharSequences.withoutSubSequence(input, 0, 2))
      .isInstanceOf(SubSequence.class).hasToString("=1,es=2");
    assertThat(CharSequences.withoutSubSequence(input, 2, 4))
      .isInstanceOf(WithoutSubSequence.class).hasToString("b3,es=2");
    assertThat(CharSequences.withoutSubSequence(input, 4, 6))
      .isInstanceOf(WithoutSubSequence.class).hasToString("b3=1s=2");
    assertThat(CharSequences.withoutSubSequence(input, 6, 8))
      .isInstanceOf(WithoutSubSequence.class).hasToString("b3=1,e2");

    assertThat(CharSequences.withoutSubSequence(input, 1, 9))
      .isInstanceOf(SubSequence.class).hasToString("b");
    assertThat(CharSequences.withoutSubSequence(input, 0, 8))
      .isInstanceOf(SubSequence.class).hasToString("2");
  }