I searched and searched and could not find what I needed, although I think it should be simple (if you have Python experience that I don't know).
Given the string, I want to check in Python that it contains ONLY alphanumeric characters: a-zA-Z0-9and. _ -
examples:
Accepted:
bill-gates
Steve_Jobs
Micro.soft
Rejected:
Bill gates - spaces are not allowed
me@host.com - @ is not alphanumeric
I am trying to use:
if re.match("^[a-zA-Z0-9_.-]+$", username) == True:
But that doesn't seem to work ...
source
share