goja-core/src/main/java/goja/core/kits/lang/CharKit.java
public static String[] splitc(String src, String d) {
        if ((d.length() == 0) || (src.length() == 0)) {
            return new String[]{src};
        }
        char[] delimiters = d.toCharArray();
        char[] srcc = src.toCharArray();

        int maxparts = srcc.length + 1;
        int[] start = new int[maxparts];
        int[] end = new int[maxparts];

        int count = 0;

        start[0] = 0;
        int s = 0, e;
        if (CharKit.equalsOne(srcc[0], delimiters)) {    // string starts with delimiter
            end[0] = 0;
            count++;
            s = CharKit.findFirstDiff(srcc, 1, delimiters);
            if (s == -1) {                            // nothing after delimiters
                return new String[]{StringUtils.EMPTY, StringUtils.EMPTY};
            }
            start[1] = s;                            // new start
        }
        while (true) {
            // find new end
            e = CharKit.findFirstEqual(srcc, s, delimiters);
            if (e == -1) {
                end[count] = srcc.length;
                break;
            }
            end[count] = e;

            // find new start
            count++;
            s = CharKit.findFirstDiff(srcc, e, delimiters);
            if (s == -1) {
                start[count] = end[count] = srcc.length;
                break;
            }
            start[count] = s;
        }
        count++;
        String[] result = new String[count];
        for (int i = 0; i < count; i++) {
            result[i] = src.substring(start[i], end[i]);
        }
        return result;
    }
public static String[] splitc(String src, String d) {
        if ((d.length() == 0) || (src.length() == 0)) {
            return new String[]{src};
        }
        char[] delimiters = d.toCharArray();
        char[] srcc = src.toCharArray();

        int maxparts = srcc.length + 1;
        int[] start = new int[maxparts];
        int[] end = new int[maxparts];

        int count = 0;

        start[0] = 0;
        int s = 0, e;
        if (CharKit.equalsOne(srcc[0], delimiters)) {    // string starts with delimiter
            end[0] = 0;
            count++;
            s = CharKit.findFirstDiff(srcc, 1, delimiters);
            if (s == -1) {                            // nothing after delimiters
                return new String[]{StringUtils.EMPTY, StringUtils.EMPTY};
            }
            start[1] = s;                            // new start
        }
        while (true) {
            // find new end
            e = CharKit.findFirstEqual(srcc, s, delimiters);
            if (e == -1) {
                end[count] = srcc.length;
                break;
            }
            end[count] = e;

            // find new start
            count++;
            s = CharKit.findFirstDiff(srcc, e, delimiters);
            if (s == -1) {
                start[count] = end[count] = srcc.length;
                break;
            }
            start[count] = s;
        }
        count++;
        String[] result = new String[count];
        for (int i = 0; i < count; i++) {
            result[i] = src.substring(start[i], end[i]);
        }
        return result;
    }
public static String [ ] splitc ( String src , String d ) { if ( ( d . length ( ) == 0 ) || ( src . length ( ) == 0 ) ) { return new String [ ] { src } ; } char [ ] delimiters = d . toCharArray ( ) ; char [ ] srcc = src . toCharArray ( ) ; int maxparts = srcc . length + 1 ; int [ ] start = new int [ maxparts ] ; int [ ] end = new int [ maxparts ] ; int count = 0 ; start [ 0 ] = 0 ; int s = 0 , e ; if ( CharKit . equalsOne ( srcc [ 0 ] , delimiters ) ) { // string starts with delimiter end [ 0 ] = 0 ; count ++ ; s = CharKit . findFirstDiff ( srcc , 1 , delimiters ) ; if ( s == - 1 ) { // nothing after delimiters return new String [ ] { StringUtils . EMPTY , StringUtils . EMPTY } ; } start [ 1 ] = s ; // new start } while ( true ) { // find new end e = CharKit . findFirstEqual ( srcc , s , delimiters ) ; if ( e == - 1 ) { end [ count ] = srcc . length ; break ; } end [ count ] = e ; // find new start count ++ ; s = CharKit . findFirstDiff ( srcc , e , delimiters ) ; if ( s == - 1 ) { start [ count ] = end [ count ] = srcc . length ; break ; } start [ count ] = s ; } count ++ ; String [ ] result = new String [ count ] ; for ( int i = 0 ; i < count ; i ++ ) { result [ i ] = src . substring ( start [ i ] , end [ i ] ) ; } return result ; }
Splits a string in several parts (tokens) that are separated by delimiter
characters. Delimiter may contains any number of character and it is
always surrounded by two strings.

@param src source to examine
@param d   string with delimiter characters
@return array of tokens
Splits a string in several parts ( tokens ) that are separated by delimiter characters . Delimiter may contains any number of character and it is always surrounded by two strings .