Here you can find the source of substringBetween(String str, String open, String close)
public static String substringBetween(String str, String open, String close)
//package com.java2s; //License from project: Apache License public class Main { private static final String EMPTY = ""; public static String substringBetween(String str, String open, String close) { if (str == null || open == null || close == null) { return null; }/* w w w . jav a 2s .c o m*/ 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; } public static String substring(String str, int start) { if (str == null) { return null; } // handle negatives, which means last n characters if (start < 0) { start = str.length() + start; // remember start is negative } if (start < 0) { start = 0; } if (start > str.length()) { return EMPTY; } return str.substring(start); } }