Java String Between between(String text, String begin, String end)

Here you can find the source of between(String text, String begin, String end)

Description

between

License

Apache License

Declaration

public static String between(String text, String begin, String end) 

Method Source Code

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

public class Main {
    public static String between(String text, String begin, String end) {
        if (text == null) {
            return null;
        }/*from w  w w  .  j av  a 2s . com*/
        int idx = text.indexOf(begin);
        if (idx < 0) {
            idx = 0;
        } else {
            idx = idx + begin.length();
        }
        int eidx = text.indexOf(end, idx);
        if (eidx < 0) {
            eidx = 0;
        }
        return text.substring(idx, eidx);
    }
}

Related

  1. between(final String string, final Integer min, final Integer max)
  2. between(String str, String left, String right)
  3. between(String str, String minstr, String maxstr)
  4. between(String text, String after, String before)
  5. between(String value, String low, String high)
  6. betweenNonGreedy(String string, String start, String end)