public static String before(String text, String before) {
        if (text == null) {
            return null;
        }
        int pos = text.indexOf(before);
        return pos == -1 ? null : text.substring(0, pos);
    }
@Test
    public void testBefore() {
        assertEquals("Hello ", StringHelper.before("Hello World", "World"));
        assertEquals("Hello ", StringHelper.before("Hello World Again", "World"));
        assertNull(StringHelper.before("Hello Again", "Foo"));

        assertTrue(StringHelper.before("mykey:ignore", ":", "mykey"::equals).orElse(false));
        assertFalse(StringHelper.before("ignore:ignore", ":", "mykey"::equals).orElse(false));

        assertEquals("", StringHelper.before("Hello World", "Test", ""));
        assertNull(StringHelper.before("Hello World", "Test", (String) null));

        assertEquals("a:b", StringHelper.beforeLast("a:b:c", ":"));
        assertEquals("", StringHelper.beforeLast("a:b:c", "_", ""));
    }