Here you can find the source of replaceAll(StringBuilder sb, String regex, String replacement)
public static StringBuilder replaceAll(StringBuilder sb, String regex, String replacement)
//package com.java2s; //License from project: Apache License import java.util.regex.*; public class Main { /**//from www . j a v a2s .c o m * The equivalent of String.replaceAll() for StringBuilder */ public static StringBuilder replaceAll(StringBuilder sb, String regex, String replacement) { Pattern pattern = Pattern.compile(regex); Matcher m = pattern.matcher(sb); int start = 0; while (m.find(start)) { sb.replace(m.start(), m.end(), replacement); start = m.start() + replacement.length(); } return sb; } }