本帖最后由 czjt1234 于 2023-4-22 20:46 编辑
vbs,另存为 ANSI 编码- s = ""
- Set oStream = CreateObject("ADODB.Stream")
- oStream.Type = 2
- oStream.Charset = "GBK" '指定文件编码
- oStream.Mode = 3
- oStream.Open()
- oStream.LoadFromFile "1.txt" '加载文件
- Do Until oStream.EOS
- t = oStream.ReadText(-2) '读取一行
- If t <> "" Then t = Chr(34) & t & Chr(34)
- s = s & t & vbCrLf
- Loop
- s = Left(s, Len(s) - 2)
- s = RePlace(s, vbCrLf, " & @CRLF & _" & vbCrLf)
- s = RePlace(s, "& _" & vbCrLf & " & @CRLF & _", "& @CRLF & _")
- oStream.Close()
- oStream.Open()
- oStream.WriteText s & " & @CRLF"
- oStream.SaveToFile "2.txt", 2
- MsgBox s & " & @CRLF"
复制代码 没用正则,就字符串替换
没处理文末有换行的情况,假定文末没有空行 |