Generate regular expressions from explicit matching and rejection requirements and validate them against representative cases.