使用正则表达式迭代字典值

时间:2018-02-16 16:59:11

标签: python zapier

在Zapier,我的触发器是标有电子邮件的标签,24小时后,如果是"回复电子邮件"不存在,运行Python以使用正则表达式提取公司名称。在提取之后,它会搜索该公司的数据库并更新记录。

我遇到的问题是使用正则表达式迭代字典并返回提取的公司名称。有人可以帮忙吗?

output = {'Subject': input_data['Subject']}
import re

subject_line= 'Signed Renewal Docs: abc company, inc.'

pat = re.compile(r'((SIGNED )?(RENEWAL )?)+(DOCS){1}( |: )+(COMPANY 
NAME|PERSONS NAME)(, | )*((INC|Incorporated)|(CORP|Corporation)|(LLC|Limited Liability Company))?((DBA)( COMPANY NAME))?', re.I)
#there are a lot of company types this is supposed to account for

for key, value in output.items():
    if re.match(value,pat):
        return COMPANY NAME
    #this is supposed to return the company name

0 个答案:

没有答案