推 CindyLinz: 你用 '...' 這種字串型式裝 regex, 應該要寫 \\\\ 07/21 16:20
※ 發信站: 批踢踢實業坊(ptt.cc), 來自: 1.163.125.50
※ 文章網址: https://www.ptt.cc/bbs/RegExp/M.1437403983.A.8E2.html
再請教一下 ,
alist = ['年\月\xa0哈囉' , 'a(bc' , '[def']
r = re.compile('[\u4e00-\u9fa5_a-zA-Z0-9]+(?!\\)')
list_new = list(filter(r.match, alist))
print(list_new)
這樣的寫法(?!\\) 應該是指不包含'\'不是嗎 ?
但執行上會有問題!
--