使用此代码,我可以删除以肯定开头的所有单词(小写字母" a"在单词的开头。但我无法获得其他版本,不考虑案例,要删除。尽管在我的re.sub语句结束时使用" re.I"有任何建议吗?
import re
txt='affirmed and the affirmance and AFFIRMED and Affirm case'
wordList = ['affirm\w+', '(ca\w+)']
for word in wordList:
txt = re.sub(word, '', txt, re.I)
print txt
输出:和AFFIRMED和确认