Verify if String matches a format String
问题 In Java, how can you determine if a String matches a format string (ie: song%03d.mp3 )? In other words, how would you implement the following function? /** * @return true if formatted equals String.format(format, something), false otherwise. **/ boolean matches(String formatted, String format); Examples: matches("hello world!", "hello %s!"); // true matches("song001.mp3", "song%03d.mp3"); // true matches("potato", "song%03d.mp3"); // false Maybe there's a way to convert a format string into a