fork download
  1. import re
  2.  
  3. s_l = ['abcabcabcabc','defdef.','sssssss','def','def,','xyzabc,','efgdefefg']
  4.  
  5. for idx, str_item in enumerate(s_l):
  6. if re.match(r'^(?=abc|def)(?!.*(?:xyz|efg)).{1,10}$(?<![,.])', str_item): #find length of str smaller than 10
  7. print(idx, "True")
  8. else:
  9. print(idx, "False")
Success #stdin #stdout 0.03s 9508KB
stdin
Standard input is empty
stdout
0 False
1 False
2 False
3 True
4 False
5 False
6 False