Move RegExp instantiation outside of the render function