Cache suitable regular expressions

This speeds up TestAllURLsMatching.test_no_duplicates by about 8000% at the cost of minimal memory overhead.