Here you can find the source of replace(String text, String find, String match, boolean useRegex, boolean isCaseSensitive)
public static String replace(String text, String find, String match, boolean useRegex, boolean isCaseSensitive)
//package com.java2s; /** This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. *//*from w ww.j av a 2 s . c o m*/ import java.util.regex.*; public class Main { public static String replace(String text, String find, String match, boolean useRegex, boolean isCaseSensitive) { if (useRegex) { if (isCaseSensitive) { return text.replaceAll(find, match); } else { return text.replaceAll("(?i)" + find, match); } } else { if (isCaseSensitive) { return text.replace(find, match); } else { return text.replaceAll("(?i)" + Matcher.quoteReplacement(find), match); } } } }