Here you can find the source of replace(Matcher m, String rv, Object value)
private static String replace(Matcher m, String rv, Object value)
//package com.java2s; /*/*www .ja v a 2 s . co m*/ * 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/. */ import java.util.regex.Matcher; public class Main { private static String replace(Matcher m, String rv, Object value) { while (m.find()) { if (m.group(2) != null) { rv = rv.replace(m.group(0), String.format(m.group(2), value)); } else { rv = rv.replace(m.group(0), String.valueOf(value)); } } return rv; } }