Prevented format from throwing an exception when there are no pattern matches.

Added test.