Here you can find the source of replace(String source, String search, String replace)
public static String replace(String source, String search, String replace)
//package com.java2s; /*//w w w. j a v a2 s. c o m * MoXie (SysTem128@GMail.Com) 2009-3-11 10:06:36 * * Copyright © 2008-2009 Zoeey.Org * Code license: GNU Lesser General Public License Version 3 * http://www.gnu.org/licenses/lgpl-3.0.txt */ import java.util.regex.Pattern; public class Main { public static String replace(String source, String search, String replace) { source = (source == null) ? "" : source; if (search == null) { return source; } replace = replace == null ? "" : replace; return Pattern.compile(Pattern.quote(search)).matcher(source).replaceAll(replace); } }