1
我新的模式匹配和具有作为这样的:字模式匹配和编译
def replaceSynonymns(title, words):
pattern = re.compile(r'\b(' + '|'.join(words) + ')\b')
title = re.sub(pattern, words[0], title)
return title
这样的一个例子,是[“网”,“互联网”,“在线”,“数字'],因此如果我们把标题设置为'我在互联网上',我们应该得到'我在网上'
但不幸的是它不工作 - 因为我不认为公司进入编译模式部分的列表是正确的 - 任何提示?