淘口令正则匹配

匹配带淘口令的Query 

# coding:utf-8
import re
f=open("query","r")
w=open("tkl_in_query","w")
readline=f.readlines()
pat_list=["₳","$","¢","₴","€","₤","¥","$","《"]
patt=[]
for key in pat_list:
    pat=re.compile(key+r"\w{11}"+key)
    patt.append(pat)
#readline=["hhhhhhhh₳WZahY5nfjwj₳hhhhhhhhhhhh"]
for line in readline:
    for pat in patt:
        if(len(pat.findall(line))>=1): #这里可以把匹配到的淘口令输出
            w.write(line)
            continue

 

你可能感兴趣的:(nlp)