Here you can find the source of getMatchingIndexes(final String source, final String match)
Parameter | Description |
---|---|
source | the text in which to search for |
match | the text to search for in source |
private static List<Integer> getMatchingIndexes(final String source, final String match)
//package com.java2s; //License from project: Open Source License import java.util.ArrayList; import java.util.List; public class Main { /**/* w w w.j a va 2 s . c o m*/ * Returns a list containing all the indexes at which {@code match} occurs in {@code source}. * * @param source * the text in which to search for * @param match * the text to search for in {@code source} * @return a list of all the indexes at which {@code match} occurrs */ private static List<Integer> getMatchingIndexes(final String source, final String match) { final List<Integer> indexes = new ArrayList<Integer>(); int index = ((source.indexOf(match) + match.length())) - 1; while (index >= 0) { while (source.charAt(index) != '{') { index++; } indexes.add(index); index = source.indexOf(match, index + 1); } return indexes; } }