Allow empty format string
Handle invalid expressions
Handle empty pattern correctly
Fixed default format regexp
Many more tests, mostly adapted from the Python test suite