code: private static Pattern replacePlaceHolders(String s) {
      s = Pattern.quote(s);
      return Pattern.compile(s.replaceAll("\\{\\d+\\}", "\\\\E.*\\\\Q"));
    }
docs: For each message such as "Not a good use of {0}", replace the place
  holder {0} with a wild card that matches all possible strings.
  Also put the any non-place-holder in quotes for regex matching later.