Here you can find the source of replace(String inputStr, String patternStr, String replacementStr)
public static String replace(String inputStr, String patternStr, String replacementStr)
//package com.java2s; //License from project: Apache License import java.util.regex.Matcher; import java.util.regex.Pattern; public class Main { public static String replace(String inputStr, String patternStr, String replacementStr) { // Compile regular expression Pattern pattern = Pattern.compile(patternStr); // Replace all occurrences of pattern in input Matcher matcher = pattern.matcher(inputStr); String output = matcher.replaceAll(replacementStr); return output; }//www. j av a2s . c om }