当使用正则表达式时,re 模块内部会干两件事情

1、编译正则表达式,如其字串本身不合法,报错

2、用编译后的正则表达式去匹配字符串

 

re_telephone = re.compile(r'^(\d{3})-{\d{3,8}}$')

re_telephone.match('010-12345').groups()

posted on 2017-07-29 00:25  啊哈咧  阅读(87)  评论(0编辑  收藏  举报