Generating a strict regular expression