fork(1) download
  1. import re
  2.  
  3. strings = [
  4. "tfd_fr_ve_t1_v1_f3_201234_yyymmmdd",
  5. "phone_football_androind_1_v1_te_t1_fe",
  6. "phone_football_ios_v1_t1",
  7. "foot_cricket2345678_f12_t4",
  8. "tfd_fr_ve_t1_v1_f3_201234_yyymmmdd",
  9. "def_000_t4_f1",
  10. "file_job_1234567_f1_t55",
  11. "ROKLOP_f33_t44",
  12. "agdcv_t45",
  13. "gop_gop_f1_t14_v14",
  14. "file_op_v1_t1",
  15. "fop_f1_v1_1223",
  16. "test"
  17. ]
  18. pattern = r"_[ftv][1-9]\d?(?!\d)"
  19. for s in strings:
  20. if re.search(pattern, s):
  21. print(f"YES, present in '{s}' ")
  22. else:
  23. print(f"NO, not present in '{s}'")
Success #stdin #stdout 0.04s 9600KB
stdin
Standard input is empty
stdout
YES, present in 'tfd_fr_ve_t1_v1_f3_201234_yyymmmdd' 
YES, present in 'phone_football_androind_1_v1_te_t1_fe' 
YES, present in 'phone_football_ios_v1_t1' 
YES, present in 'foot_cricket2345678_f12_t4' 
YES, present in 'tfd_fr_ve_t1_v1_f3_201234_yyymmmdd' 
YES, present in 'def_000_t4_f1' 
YES, present in 'file_job_1234567_f1_t55' 
YES, present in 'ROKLOP_f33_t44' 
YES, present in 'agdcv_t45' 
YES, present in 'gop_gop_f1_t14_v14' 
YES, present in 'file_op_v1_t1' 
YES, present in 'fop_f1_v1_1223' 
NO, not present in 'test'