title: Verify if String matches a format String
body: <p>In Java, how can you determine if a String matches a <a href="http://download.oracle.com/javase/1,5.0/docs/api/java/util/Formatter.html#syntax">format string</a> (ie: <code>song%03d.mp3</code>)?</p>
  
  <p>In other words, how would you implement the following function?</p>
  
  <pre><code>/**
  * @return true if formatted equals String.format(format, something), false otherwise.
  **/
  boolean matches(String formatted, String format);
  </code></pre>
  
  <p>Examples:</p>
  
  <pre><code>matches("hello world!", "hello %s!"); // true
  matches("song001.mp3", "song%03d.mp3"); // true
  matches("potato", "song%03d.mp3"); // false
  </code></pre>
  
  <p>Maybe there's a way to convert a format string into a regex?</p>
  
  <h2>Clarification</h2>
  
  <p>The format String is a parameter. I don't know it in advance. <code>song%03d.mp3</code> is just an example. It could be any other format string.</p>
  
  <p>If it helps, I can assume that the format string will only have one parameter.</p>