0

I wonder if someone could help me solving this problem, I've tried this 2 regex but no success. I wonder if I'm doing wrong anywhere in the expression?

string[1] = "MixEdCasE"
string[2] = "MiXeD CaSE"    
re.search("^(?=.*[a-z])(?=.*[A-Z])(?=.*[0-9])[a-zA-Z0-9]{8}$", string[num])
re.search(r'(?=.*[a-z])(?=.*[A-Z])(?=.*[0-9])[a-zA-Z0-9]{8}$', string[num])
Natsume
  • 881
  • 3
  • 15
  • 22

1 Answers1

0

This pattern works well:

re.search(r'^(?=.*[a-z])(?=.*[A-Z])(?=.*[0-9])[a-zA-Z0-9]{8}$', string[num])

The problem is that your example strings contain more than 8 characters.

Casimir et Hippolyte
  • 88,009
  • 5
  • 94
  • 125