加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 百科 > 正文

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

发布时间:2020-12-14 06:46:13 所属栏目:百科 来源:网络整理
导读: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

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!'}

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读