re模块
1.match()方法:
1.match()
判断是否匹配,如果匹配成功,返回一个Match对象,否则返回None
Match
None
#示例1:test1='012-12345678' if re.match(r'^d{3}-d{3,8}$',test1): print('yes') else: print('failed')#输出 #yes#说明: ^表示从行头开始匹配,$表示行的结尾,匹配3个数字加-然后3-8个数字