Java String Between between(String str, String left, String right)

Here you can find the source of between(String str, String left, String right)

Description

between

License

Apache License

Declaration

public static String between(String str, String left, String right) 

Method Source Code

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

public class Main {

    public static String between(String str, String left, String right) {
        int leftIndex = str.indexOf(left);
        int rightIndex = str.lastIndexOf(right);
        // if (leftIndex == -1) {
        // leftIndex = 0;
        // }//ww  w. j  a v a 2 s  .  c  o  m
        if (rightIndex == -1) {
            rightIndex = str.length();
        }
        return str.substring(leftIndex + left.length(), rightIndex);
    }
}

Related

  1. between(final String string, final Integer min, final Integer max)
  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)