Update regex to handle extra whitespace in query