init the regexPatternCache if it doesn't exist

I just encountered a small issue in my implementation and here's the code to fix it.