Java String Index Of getIndexOfChar(String str, String start, String end)

Here you can find the source of getIndexOfChar(String str, String start, String end)

Description

get Index Of Char

License

Open Source License

Declaration

public static List<Integer> getIndexOfChar(String str, String start, String end) 

Method Source Code

//package com.java2s;
//License from project: Open Source License 

import java.util.ArrayList;
import java.util.List;

public class Main {
    public static List<Integer> getIndexOfChar(String str, String start, String end) {
        int starIndex = 0;
        List<Integer> list = new ArrayList<Integer>();
        while (true) {
            int a = 0;
            if (list.size() % 2 == 0) {
                a = str.indexOf(start, starIndex);
            } else {
                a = str.indexOf(end, starIndex);
            }//from   w w  w.ja  v  a 2s  . co  m

            if (a == -1) {
                break;
            }
            list.add(a);
            starIndex = a + 1;
        }
        return list;
    }
}

Related

  1. getAllIndex(String source, String rex)
  2. getIndexesOf(String word, String value)
  3. getIndexOrConstraintName(String command)
  4. getIndexString(T array, String indexPrefix, String separatorPrefix)
  5. getLowerBoundsOfAllStrings(int length, int seedIndex, int routeLength)
  6. getMatchingIndexes(final String source, final String match)