I need to write func to check str. If should fit next conditions:
1) str should starts with alphabet - ^[a-zA-Z]
2) str should contains alphabet, numbers, . and - ([\w]+*.-)
3) str should ends with alphabet or number - \w$
4) length of str should be from 10 to 50
def check_login(str):
flag = False
if match(r'^[a-zA-Z]([\w]*.-)\w${10, 50}', str):
flag = True
return flag
It returns False to all combinations.
I think, error in 2 condition. I know, that I can use [a-zA-Z0-9\.-]+, but it does not indicate a mandatory entry.
How can I fix that?
\wcontains also underscore_.and-mandatory? ie. at least one of them?return match(r'^[a-zA-Z]([\w]*.-)\w${10, 50}', str)as that will return the boolean resulting from thematchfunction. No need to define and return flags separately like that.${10, 50}is a nonsense.