Java String Find multiFindBetween(String source, String pre, String post)

Here you can find the source of multiFindBetween(String source, String pre, String post)

Description

multi Find Between

License

Open Source License

Declaration

public static List<String> multiFindBetween(String source, String pre, String post) 

Method Source Code

//package com.java2s;
/*/*w ww  . j  a v a  2  s .c om*/
 * Copyright (c) Erasmus MC
 *
 * This file is part of TheMatrix.
 *
 * TheMatrix is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program. If not, see <http://www.gnu.org/licenses/>.
 */

import java.util.ArrayList;

import java.util.List;

public class Main {
    public static List<String> multiFindBetween(String source, String pre, String post) {

        List<String> result = new ArrayList<String>();

        int start = 0;

        int end = 0;

        while (start != -1 && end != -1) {

            start = source.indexOf(pre, end);

            if (start != -1) {

                end = source.indexOf(post, start + pre.length());

                if (end != -1)

                    result.add(source.substring(start + pre.length(), end));

            }

        }

        return result;

    }
}

Related

  1. findResourceBundle(String aBundleName, Locale locale)
  2. getAllOccurences(String str, char guess)
  3. getOccurenceIndices(String inSubject, String inOccurence)
  4. getSearchTermOccurrences(final String searchTerm, final String content)
  5. indexOfOccurance(String s1, String s2, Integer i)