public ArrayList<Integer> findStart(String patten, String str) {
        ArrayList<Integer> next = new ArrayList<>();
        ArrayList<Integer> startIndexList = new ArrayList<>();
        next.add(0);
        for (int i = 1, j = 0; i < patten.length(); i++) {
            while (j > 0 && patten.charAt(i) != patten.charAt(j)) {
                j = next.get(j - 1);
            }
            if (patten.charAt(i) == patten.charAt(j)) {
                j++;
            }
            next.add(j);
        }
        for (int i = 0, j = 0; i < str.length(); i++) {
            while (j > 0 && str.charAt(i) != patten.charAt(j)) {
                j = next.get(j - 1);
            }
            if (str.charAt(i) == patten.charAt(j)) {
                j++;
            }
            if (j == patten.length()) {
                startIndexList.add(i - patten.length() + 1);
                j = 0;
            }
        }
        return startIndexList;
    }
Use kmp to find all the starting subscripts of the pattern from str

@param patten Pattern string
@param str    target string
@return starting index list
inlong-sdk/transform-sdk/src/main/java/org/apache/inlong/sdk/transform/process/function/string/SubstringIndexFunction.java