Here you can find the source of subStringIgnoreCase(String str, String separator, Integer stratNum, Integer endNum)
public static final String subStringIgnoreCase(String str, String separator, Integer stratNum, Integer endNum)
//package com.java2s; //License from project: Open Source License public class Main { /**@see #subString(String, String, Integer, Integer, Boolean) * @author hcqt@qq.com*///from w ww. java 2s . c o m public static final String subStringIgnoreCase(String str, String separator, Integer stratNum, Integer endNum) { return subString(str, separator, stratNum, endNum, true); } /**@see #subString(String, String, Integer, Integer, Boolean) * @author hcqt@qq.com*/ public static final String subString(String str, String separator, Integer stratNum, Integer endNum) { return subString(str, separator, stratNum, endNum, false); } /**@author hcqt@qq.com*/ public static final String subString(String str, String separator, Integer stratSeparatorNum, Integer endSeparatorNum, Boolean ignoreCase) { if (str == null || separator == null || stratSeparatorNum == null || endSeparatorNum == null) { return null; } int startIndex = indexOf(str, separator, stratSeparatorNum, ignoreCase); if (startIndex == -1) { return null; } startIndex = startIndex + separator.length(); int endIndex = indexOf(str, separator, endSeparatorNum, ignoreCase); if (endIndex == -1) { return null; } if (startIndex >= endIndex) { return null; } return str.substring(startIndex, endIndex); } /**@see #indexOf(String, String, Integer, Boolean) * @author hcqt@qq.com*/ public static final int indexOf(String str, String separator, Integer num) { return indexOf(str, separator, num, false); } public static final int indexOf(String str, String separator, Integer num, Boolean isIgnoreCase) { if (isIgnoreCase == null) { isIgnoreCase = Boolean.FALSE; } if (null == str) { return -1; } if (null == separator) { return -1; } if (isIgnoreCase) { str = str.toUpperCase(); separator = separator.toUpperCase(); } if (null == num) { num = Integer.valueOf(0); } if (Integer.signum(num) == 0) { return -1; } else if (Integer.signum(num) == 1) { int j = -1; for (int i = 0; i < num; i++) { if (j == -1) { j = str.indexOf(separator, 0); } else { j = str.indexOf(separator, j + 1); } if (j == -1) { break; } } return j; } else if (Integer.signum(num) == -1) { int j = -1; for (int i = 0; i < Math.abs(num); i++) { if (j == -1) { j = str.lastIndexOf(separator); } else { j = str.lastIndexOf(separator, j - 1); } if (j == -1) { break; } } return j; } return -1; } }