Python Match String To Pattern Blocks