Make the regex search fast
We are creating the regexes all the time which is a lot of useless and very expensive work. Instead cache them inside the function and only reconstruct if the pattern actually changed
There is also a fix for ignoring the "multiline" option after "repairPattern" which I think got accidentally removed a while ago.