Yes, the behaviour is probably closer to `trimAndCollapseFrom` rather than `collapseFrom`. If we change to that, the following would hold, and I think it's sensible:

    assertEquals(matcher.trimAndCollapseFrom("$$$abc$$$def$$$", '_'), "abc_def");
    assertEquals(matcher.trimAndCollapseFrom("a.b.c.d   ", '_'), "a.b.c.d");