Java String Between betweenNonGreedy(String string, String start, String end)

Here you can find the source of betweenNonGreedy(String string, String start, String end)

Description

between Non Greedy

License

Apache License

Declaration

public static String betweenNonGreedy(String string, String start, String end) 

Method Source Code

//package com.java2s;
//License from project: Apache License 

public class Main {
    public static String betweenNonGreedy(String string, String start, String end) {
        int startIndex = string.indexOf(start);
        int searchFrom = startIndex + start.length();
        String between;/*  w  w  w  . j av  a2  s  .  com*/
        if (searchFrom == string.length()) {
            between = "";
        } else {
            int endIndex = string.indexOf(end, searchFrom);
            if (endIndex != -1) {
                int startPoint = searchFrom;
                if (startPoint > endIndex) {
                    between = null;
                } else {
                    between = string.substring(searchFrom, endIndex);
                }
            } else {
                between = null;
            }
        }

        return between;
    }
}

Related

  1. between(String str, String left, String right)
  2. between(String str, String minstr, String maxstr)
  3. between(String text, String after, String before)
  4. between(String text, String begin, String end)
  5. between(String value, String low, String high)