正则表达式匹配 --所有语言通用

前端之家收集整理的这篇文章主要介绍了正则表达式匹配 --所有语言通用前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。

uri的校验 匹配 http://0.0.0.0:55

nd = {}
nd['uuid'] = uuid.encode('utf-8')
res = re.match(r"(http://){1}([\d]{2,3}([.]{1}" +
"[\d]{1,3}){3}[:]{1}[\d]{2,5}){1}",uri)
if res == None:
return http_client.BAD_REQUEST,{'error': 'uri illegal'}
if 'gffgfgg' and 'ghrefgfg' not in body.keys():
LOG.error('create Failed with body paras error')
return http_client.BAD_REQUEST,{'error': 'create error'}
nd['dcId'] = body['dcId'].encode('utf-8')



变量匹配 小写字母打头 只包含字母和数字的

m1 = re.match(r"(^[a-z]){1}",bianliang)
m2 = re.search(r"([^a-z0-9])+",bianliang)
if m1 == None and m2:
return http_client.BAD_REQUEST,{'error': 'params bianliangillegal!'}

原文链接:https://www.f2er.com/regex/358092.html

猜你在找的正则表达式相关文章