Add test for regex cache retention. #2078.