@Nonnull
    public List<String> getSplits(String value, List<Pair<Integer, Integer>> splitList, int first, int last) {
        int lastIndex = last - 1;
        int firstIndex = first - 1;
        int splits = splitList.size();

        if (last == -1) {
            lastIndex = splits - 1;
        }
        if (lastIndex >= splits) {
            lastIndex = splits - 1;
        }
        if (firstIndex < 0 || lastIndex < 0) {
            return Collections.emptyList();
        }
        if (firstIndex >= splits) {
            return Collections.emptyList();
        }

        List<String> result = new ArrayList<>();
        for (int split = firstIndex; split <= lastIndex; split++) {
            Pair<Integer, Integer> splitPair = splitList.get(split);
            result.add(value.substring(splitPair.getLeft(), splitPair.getRight()));
        }
        return result;
    }
Find the start offset of split

@param chars The input in which we are seeking
@param split  The split number for which we are looking for the start
@return The offset or -1 if it does not exist
analyzer/src/main/java/nl/basjes/parse/useragent/utils/Splitter.java