标签:正整数 正则表达式 mat 表达式 个数 下划线 bsp port nbsp
# # 密码强度正则,最少6位,包括至少1个大写字母,1个小写字母,1个数字,1个特殊字符
import re
if re.match(r‘^(?=.*?[A-Z])(?=.*?[a-z])(?=.*?[0-9])(?=.*?[#?!@$%^&*-]).{6,}$‘,"1aZ1-1211"):
print("匹配")
#正整数正则
if re.match(r‘^\d+$‘,"42"):
print("匹配")
#负整数正则
if re.match(r‘^-\d+$‘,"42"):
print("匹配")
#整数正则
if re.match(r‘^-?\d+$‘,"-42"):
print("匹配")
#正整数正则
if re.match(r‘^\d*\.?\d+$‘,"42.3"):
print("匹配")
#负整数正则
if re.match(r‘^-\d*\.?\d+$‘,"-42.2"):
print("匹配")
#整数正则
if re.match(r‘^-?\d*\.?\d+$‘,"-42.32"):
print("匹配")
#邮箱匹配
if re.match(r‘^([A-Za-z0-9_\-\.])+\@([A-Za-z0-9_\-\.])+\.([A-Za-z]{2,4})$‘, "153522217@qq.com"):
print("匹配")
# 4到16位(字母,数字,下划线,减号)用户匹配
if re.match(r‘^[a-zA-Z0-9_-]{4,16}$‘, "abwc"):
print("匹配")
标签:正整数 正则表达式 mat 表达式 个数 下划线 bsp port nbsp
原文地址:https://www.cnblogs.com/zrf-516/p/9033607.html