fork download
  1. import re
  2.  
  3. strings = [
  4. 'a1b2c$3d#4e!f@ghi0',
  5. 'test$test$test123'
  6. ]
  7.  
  8. for str in strings:
  9. sym = r'^[^!@#$%&*\r\n]*[!@#$%&*][^!@#$%&*\r\n]*[!@#$%&*][^!@#$%&*\r\n]*\Z'
  10. num = r'^[^\d\r\n]*\d[^\d\r\n]*\d'
  11.  
  12. if re.search(sym, str) and re.search(num, str):
  13. print(f'match! {str}')
  14. else:
  15. print(f'no match! {str}')
Success #stdin #stdout 0.02s 9532KB
stdin
Standard input is empty
stdout
no match! a1b2c$3d#4e!f@ghi0
match! test$test$test123