fork download
  1. import re
  2.  
  3. s = r'Z[RSTU][0-9][A-Z]{1,3}(?:-[0-9]{1,2})?'
  4.  
  5. rex = re.compile(s)
  6. for test in ('ZU2A', 'ZS6D-9', 'ZT0ER-7', 'ZR6PJH-12'):
  7. assert rex.match(test), test
  8.  
  9. long_test = 'ZU0D>APT314,ZT1ER,WIDE1,ZS3PJ-2,ZR5STU-12*/V:/021414z2610.07S/02814.02Ek067/019/A=005475!w%<!'
  10. found = rex.findall(long_test)
  11. assert found == ['ZU0D', 'ZT1ER', 'ZS3PJ-2', 'ZR5STU-12'], found
  12.  
Success #stdin #stdout 0.02s 8736KB
stdin
Standard input is empty
stdout
Standard output is empty