I need to write func to check str. If should fit next conditions:
1) str should starts with alphabet - ^[a-zA-Z]
2) str may contains alphabet, numbers, one . and one -
3) str should ends with alphabet or number
4) length of str should be from 1 to 50
def check_login(str):
flag = False
if match(r'^[a-zA-Z][a-zA-Z0-9.-]{1,50}[a-zA-Z0-9]$', str):
flag = True
return flag
But it should mean that it starts with alphabet, length of [a-zA-Z0-9.-] is more than 0 and less 51 and it ends with [a-zA-Z0-9].
How can I limit quantity of . and - and write length's limit to all expression?
I mean that a - should returns true, qwe123 also true.
How can I fix that?