Here you can find the source of substringBetween(String str, String open, String close, int fromIndex)
public static String substringBetween(String str, String open, String close, int fromIndex)
//package com.java2s; /*(C) 2007-2012 Alibaba Group Holding Limited. *This program is free software; you can redistribute it and/or modify *it under the terms of the GNU General Public License version 2 as * published by the Free Software Foundation. * Authors: /*from w w w. java 2 s . c o m*/ * junyu <junyu@taobao.com> , shenxun <shenxun@taobao.com>, * linxuan <linxuan@taobao.com> ,qihao <qihao@taobao.com> */ public class Main { public static String substringBetween(String str, String tag) { return substringBetween(str, tag, tag, 0); } public static String substringBetween(String str, String open, String close) { return substringBetween(str, open, close, 0); } public static String substringBetween(String str, String open, String close, int fromIndex) { if ((str == null) || (open == null) || (close == null)) { return null; } int start = str.indexOf(open, fromIndex); if (start != -1) { int end = str.indexOf(close, start + open.length()); if (end != -1) { return str.substring(start + open.length(), end); } } return null; } }