Java tutorial
//package com.java2s; //License from project: Apache License import java.util.regex.*; public class Main { public static StringBuffer removePatternContents(String defStr, Pattern pat) { Matcher mat = pat.matcher(defStr); StringBuffer sb = new StringBuffer(); while (mat.find()) { mat.appendReplacement(sb, " "); } mat.appendTail(sb); return sb; } }