Make regex compiling more robust