Here you can find the source of getAllIndex(String source, String rex)
public static int[] getAllIndex(String source, String rex)
//package com.java2s; //License from project: Apache License import java.util.*; public class Main { public static int[] getAllIndex(String source, String rex) { ArrayList<Integer> list = new ArrayList<Integer>(); int position = 0; while (position < source.length()) { int index = source.indexOf(rex, position); if (index > -1) { list.add(source.indexOf(rex, position)); position = index + 1;/*w ww .j a va 2 s. co m*/ } else { break; } } int[] ins = new int[list.size()]; for (int i = 0; i < ins.length; i++) { ins[i] = list.get(i); } return ins; } }