fork download
  1. import re
  2.  
  3. strings = [
  4. "t1E2S3T",
  5. "t1E2S33"
  6. ]
  7.  
  8. def emne_validator(emne):
  9. pattern = r"(?=(?:[^a-zA-Z\n]*[a-zA-Z]){4}[^a-zA-Z\n]*\Z)(?=(?:[^\d\n]*\d){3}[^\d\n]*\Z)"
  10. m = re.match(pattern, emne)
  11. return m is not None
  12.  
  13. for txt in strings:
  14. result = emne_validator(txt)
  15. if result:
  16. print(f"Valid input for: {txt}")
  17. else:
  18. print(f"Invalid input for: {txt}")
Success #stdin #stdout 0.03s 9504KB
stdin
Standard input is empty
stdout
Valid input for: t1E2S3T
Invalid input for: t1E2S33