[問題] 關於正則匹配已刪文

看板Python作者 (*+Red)時間2年前 (2021/07/05 23:57), 編輯推噓1(100)
留言1則, 1人參與, 2年前最新討論串1/1
def tokenlize(content): content=re.sub("<.*?>"," ", content) filters= ['/t','/n','/x97','/x96','$','#','&','$','"','\"','\''] content= re.sub("|".join(filters)," ",content) tokens= [i.strip() for i in content.split()] return tokens 想跟大家請教一下 關於分詞的問題, 假如把讀出的文字檔簡單分詞的話 如果檔案中出現多次的單/雙引號 我的filters該怎麼寫才能把他們替換掉啊? str=' It is good 'to' hear about "you".' -- ※ 發信站: 批踢踢實業坊(ptt.cc), 來自: 36.224.181.213 (臺灣) ※ 文章網址: https://www.ptt.cc/bbs/Python/M.1625500626.A.474.html

07/06 00:31, 2年前 , 1F
google “escape in regex”
07/06 00:31, 1F
文章代碼(AID): #1WuolIHq (Python)