【发布时间】:2012-03-06 08:57:12
【问题描述】:
我有一个可以任意长的字符串
s = 'Choose from millions of possibilities on Shaadi.com. Create your profile, search&contact; your special one.RegisterFree\xa0\xa0\xa0unsubscribing reply to this mail\xa0\n and 09times and this is limited time offer! and this is For free so you are saving cash'
我有一个垃圾邮件列表,可能像
p_words = ['cash', 'for free', 'limited time offer']
我只想知道输入文本中是否存在模式以及存在多少次?
只有一个字就变简单了
import re
p = re.compile(''.join[p_words]) # correct me if I am wrong here
m = p.match(s)
但它可能是bi-gram, tri-gram or n-gram
我们如何处理这个问题?
【问题讨论】: