本帖最后由 WHY 于 2023-4-10 07:26 编辑
我贴一个vbs,0.03s 左右- ST = Timer
-
- Dim srcFile, dstFile
- srcFile = "a.txt"
- dstFile = "b.txt"
-
- Dim fso, objFile
- Set fso = CreateObject("Scripting.FileSystemObject")
- Set objFile = fso.OpenTextFile(srcFile, 1)
-
- Dim strIn, strLine
- strIn = ""
- Do Until objFile.AtEndOfStream
- strLine = objFile.ReadLine
- If strLine <> "" Then strIn = strLine & strIn
- Loop
-
- Dim reg
- Set reg = New RegExp
- reg.Global = True
-
- Dim strOut, i, key, match
- strOut = ""
- For i = Len(strIn)-1 To 1 Step -1
- key = Left(strIn, i)
- If InStr(2, strIn, key) > 0 Then
- reg.Pattern = ".(?=" & key & ")"
- For Each match In reg.Execute(strIn)
- strOut = strOut & match & vbCrLf
- Next
- Exit For
- End If
- Next
-
- fso.OpenTextFile(dstFile, 2, True).Write(strOut)
-
- MsgBox Timer - ST
复制代码
|