Fixed test condition to more accurately fail as intended.
Compile patterns once. Take care with appendReplacement; special chars