首页 > 技术文章 > 用不到就根本记不住之正则

yanhui1995 2019-10-28 16:27 原文

re 模糊匹配

USER_REGULATION = [
    {"method": ["GET", "PUT", "POST"], "pattern": "store/.*/pictures"},
    {"method": ["GET", "PUT", "POST"], "pattern": "users/.*"},
]

 

list = []

def text():

    for item in USER_REGULATION:
        regex = re.compile(item["pattern"])
        match = regex.search(path_url)
        if match:

    list.append(item)

 

推荐阅读