Splits data into an array by the separator, except if in the exclude regions

@param {String} data The string to split
@param {String} separator The separator
@param {Array<{start: Number, end: Number}>} exclude The boundaries to exclude
@returns {Array<String>} The separated array
function splitOutside(data, separator, exclude) {
    var result = [];

    var accumulator = "";
    for (var i = 0; i < data.length; i++) {
        accumulator += data[i];

        var isInExclusion = inPosition(i, exclude);
        if (!isInExclusion && endsWith(accumulator, separator)) {
            result.push(accumulator.substring(0, accumulator.length - separator.length));
            accumulator = '';
        }
    }
    result.push(accumulator);
    return result;
}