Here you can find the source of replaceAllIgnoreCase(String source, String oldstring, String newstring)
public static String replaceAllIgnoreCase(String source, String oldstring, String newstring)
//package com.java2s; //License from project: Apache License import java.util.regex.Matcher; import java.util.regex.Pattern; public class Main { public static String replaceAllIgnoreCase(String source, String oldstring, String newstring) { Pattern p = Pattern.compile(oldstring, 34); Matcher m = p.matcher(source); return m.replaceAll(newstring); }/* w w w .j a v a2 s. c o m*/ public static String replaceAll(String content, String targetWord, String replaceWord) { int lastIndex; if (content == null) return null; StringBuffer text = new StringBuffer(); int contentLength = content.length(); int targetWordLenght = targetWord.length(); int startIndex = 0; while ((lastIndex = content.indexOf(targetWord, startIndex)) >= 0) { text.append(content.substring(startIndex, lastIndex)); text.append(replaceWord); startIndex = lastIndex + targetWordLenght; } if (startIndex < contentLength) { text.append(content.substring(startIndex)); } return text.toString(); } public static int indexOf(String str, char strChar) { if (isEmpty(str)) { return -1; } return str.indexOf(strChar); } /** * <pre> * ExmayStringUtils.indexOf(null, *) = -1 * ExmayStringUtils.indexOf(*, null) = -1 * ExmayStringUtils.indexOf("", "") = 0 * ExmayStringUtils.indexOf("aabaabaa", "a") = 0 * ExmayStringUtils.indexOf("aabaabaa", "b") = 2 * ExmayStringUtils.indexOf("aabaabaa", "ab") = 1 * ExmayStringUtils.indexOf("aabaabaa", "") = 0 * </pre> * * @param str * @param searchStr * @return */ public static int indexOf(String str, String searchStr) { if (str == null || searchStr == null) { return -1; } return str.indexOf(searchStr); } public static int indexOf(String str, char searchChar, int startPos) { if (isEmpty(str)) { return -1; } return str.indexOf(searchChar, startPos); } public static String subString(String src, int length) { if (src == null) { return null; } int i = src.length(); if (i > length) { return src.substring(0, length); } return src; } public static boolean isEmpty(String str) { return str == null || str.length() == 0 || str.equals("") || str.matches("\\s*"); } }