public static String substitute(final String input, final String pattern, final String sub) {
        StringBuilder ret = new StringBuilder(input.length());
        int start = 0;
        int index = -1;
        final int length = pattern.length();
        while ((index = input.indexOf(pattern, start)) >= start) {
            ret.append(input.substring(start, index));
            ret.append(sub);
            start = index + length;
        }
        ret.append(input.substring(start));
        return ret.toString();
    }
@Test
    public void testSub1() throws Exception {
        String input = "http://jakarta.apache.org/jmeter/index.html";
        String pattern = "jakarta.apache.org";
        String sub = "${server}";
        assertEquals("http://${server}/jmeter/index.html", StringUtilities.substitute(input, pattern, sub));
    }