美文网首页
python 中文 正则

python 中文 正则

作者: g0 | 来源:发表于2018-03-08 12:25 被阅读289次

import re
#----------------------------------------------------------------------
def find():
    """"""
    with open('1.html') as f:
        for i in f.readlines():
            try:
                i = i.decode('utf8')
                hh  = re.findall(u'(CVE-.{4}\u5e74\u81f3\d{4}\u5e74)', i)
                hh2 = re.findall(u'(CVE-.{4}\u81f3\d{4}\u5e74)', i)
                
                bb = hh + hh2
                for j in bb:
                    j1 = re.sub('\u5e74', '', j)
                    j2 = re.sub('\u81f3', '-', j1)
                    print j2
    
            except Exception,e:
                pass
    
#find()

#i = 'CVE-2010年至2531年klklkCVE-2O10至2531年'
#i = i.decode('utf-8')
#print re.findall(u'年', i)
#print re.findall(u'至', i)
with open('1.html') as f:
    for i in f.readlines():
        #print re.findall(u'CVE-\d{4}\xc4\xea\xd6\xc1\d{4}\xc4\xea', i)
        i = i.decode('utf8')
        hh  = re.findall(u'\u5e74\u81f3', i)
        print hh
        #hh2 = re.findall(u'CVE-.{4}', i)

        bb = hh 
        print bb
        for j in bb:
            j1 = re.sub('\xc4\xea', '',j)
            j2 = re.sub('\xd6\xc1', '-', j1)
            print j2

    
    




image.png

相关文章

网友评论

      本文标题:python 中文 正则

      本文链接:https://www.haomeiwen.com/subject/itxyfftx.html