String input = "SELECT * FROM BUYLIST" +
" WHERE MANAGER_NAME = '{DATASET.DATASET1}'";
String pattern = "\\'\\{[Dd][Aa][Tt][Aa][Ss][Ee][Tt]\\.[Dd][Aa][Tt][Aa][Ss][Ee][Tt][1]\\}\\'";
Pattern p = Pattern.compile(pattern);
Matcher m = p.matcher(input);
System.out.println("Input Before : " + input);
StringBuffer sb = new StringBuffer();
int replacementCount = 0;
while (m.find()) {
System.out.println(++replacementCount + ". Matches : " + m.start() +"-" + m.end());
m.appendReplacement(sb, "?");
}
m.appendTail(sb);
System.out.println("Replacement Count : " + replacementCount);
System.out.println("Input After : " + sb.toString());