public static String escape(final String text, final Predicate<Character> toEscape, final Character escapeChar) {
        final StringBuilder sb = new StringBuilder();
        for (char c : text.toCharArray()) {
            if (toEscape.test(c)) {
                sb.append(escapeChar == null ? c : escapeChar);
            }
            sb.append(c);
        }
        return sb.toString();
    }
Parses text until a 'stopper' char is reached. Places pos after this stopper char and returns parsed text.
Returns null if no stopper char is found

@param stopper               chars to stop parsing at
@param endIsDelim            if true, then 'end-of-expression' is treated like finding a stopper char
@param escapeChar            if not null, then characters escapced with this char will not be considered stopper chars but parsed as literal char
@param escapeDoubledStoppers if true, then doubled up stopper chars will not be considered stoppers but parsed as single literal chars
main/src/main/java/cgeo/geocaching/utils/TextParser.java