I have this code:
# If the username isn't alpha-numerics (inc: _, -, ., )
if re.match('^[a-zA-Z0-9 _\-\.]+$', repName) == False:
print 'DECLINE: '+repName
else:
print 'ACCEPTED: '+repName
And when i test it against this string: ɢ开发者_如何学JAVAᴀꜱᴛяɪᴄ (which is grabbed from a website) I get this returned:
ACCEPTED: ɢᴀꜱᴛÑ?ɪᴄ
Why is this getting through? Also why does Python seem to change the string?
Unsuccessful re.match
is not False
. It is None
.
But you can also try it this way:
if re.match('^[a-zA-Z0-9 _\-\.]+$', repName):
print 'ACCEPTED: '+repName
else:
print 'DECLINE: '+repName
精彩评论