Add function to generate regex to capture an expression