2013-08-07 23:18:39|
- 检测用户名,长度为2-20位,可以包含英文字母、数字、下划线,以字母或数字开头,以字母或数字结束,字母区分大小写。
import re rule = re.compile(r'^[a-zA-Z0-9][a-zA-Z0-9_]{0,18}[a-zA-Z0-9]$') # 将正则表达式编译成Pattern对象 str_match = rule.match(username) if str_match: print True
zifenger 2014-01-12 12:36 原文
2013-08-07 23:18:39|
import re rule = re.compile(r'^[a-zA-Z0-9][a-zA-Z0-9_]{0,18}[a-zA-Z0-9]$') # 将正则表达式编译成Pattern对象 str_match = rule.match(username) if str_match: print True