Cache regex in a local variable