利用sublime text的正则表达式解决问题

小说里的章节用 数字、 来划分,
如何用sublime text将这些 数字、 替换成 第 数字 章

远程看看吧

import re
strs=""
with open("2.txt","r",encoding="utf-8") as fp:

txt=fp.readline()
while txt:
    tlist=re.findall("\d+、",txt)
    if tlist:
        temp=tlist[0].replace("、","")
        # print(temp)
        txt=txt.replace(temp+"、","第"+temp+"章  ")
        print(txt)
    strs=strs+txt
    txt = fp.readline()

with open("1.txt","a",encoding="utf-8") as f:
f.write(strs)

import re

sdf="你好34 你好 345"

print(re.findall("\d+、",sdf))

for it in re.findall("\d+、",sdf):

temp=it.replace("、","")

sdf=sdf.replace(it,"第"+temp+"章")

print(sdf)

print(sdf.replace("\d+、","第1章"))