你可以使用正则表达式的|操作符来匹配多个可能的字段名,下面是一个通用的示例代码:

import re

data = {'network': 'ws', 'security': 'none', 'wsSettings': {'acceptProxyProtocol': False, 'path': '/', 'headers': {'Host': 'ir.helma.ir'}}}

# 定义可能的字段名
possible_fields = ['wsSettings', 'tlsSettings', 'grpcSettings']

# 构建正则表达式
pattern = r'({})'.format('|'.join(possible_fields))

# 使用正则表达式查找匹配的字段
matched_fields = re.findall(pattern, str(data))

# 输出匹配到的字段
print(matched_fields)

输出结果会是一个包含匹配到的字段名的列表,例如:['wsSettings']。你可以根据需要进行进一步处理

python 正则查找network ws security none wsSettings acceptProxyProtocol False path headers Host irhelmair 里面的wsSettings但是有可能它会变成tlsSettings和grpcSettings或者别的给我一个通用匹配的

原文地址: https://www.cveoy.top/t/topic/hOuV 著作权归作者所有。请勿转载和采集!

免费AI点我,无需注册和登录