Java String Sub String substringBetween(String str, String open, String close)

Here you can find the source of substringBetween(String str, String open, String close)

Description

substring Between

License

LGPL

Declaration

public static String substringBetween(String str, String open, String close) 

Method Source Code

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

public class Main {
    public static String substringBetween(String str, String open, String close) {
        if (str == null || open == null || close == null) {
            return null;
        }//from   w w  w .  j  a  v a 2s  .  c om
        int start = str.indexOf(open);
        if (start != -1) {
            int end = str.indexOf(close, start + open.length());
            if (end != -1) {
                return str.substring(start + open.length(), end);
            }
        }
        return null;
    }
}

Related

  1. substringBetween(String s, String part1, String part2)
  2. substringBetween(String s, String part1, String part2)
  3. substringBetween(String source, String strBegin, String strEnd)
  4. substringBetween(String str, String before, String after)
  5. substringBetween(String str, String open, String close)
  6. substringBetween(String str, String open, String close)
  7. substringBetween(String str, String open, String close, int fromIndex)
  8. substringBetween(String str, String pos1, String pos2)
  9. substringBetween(String str, String tag)