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?
There is not a simple way to do this. A straight-forward way would be to write some code that converts format strings (or a simpler subset of them) to regular expressions and then match those using the standard regular expression classes.
A better way is probably to rethink/refactor your code. Why do you want this?