741
社区成员
发帖
与我相关
我的任务
分享
Option Explicit
Private Sub Command1_Click()
List1.Clear
Dim re As New RegExp
Dim ms As MatchCollection, m As Match, i As Integer, j As Integer
With re
.MultiLine = True
.Global = True
.IgnoreCase = True
.Pattern = "([^\n]+\n)"
Set ms = .Execute(Text1)
For i = 0 To ms.Count - 1
For j = 0 To i - 1
If ms(i) = ms(j) Then Exit For
Next
If j = i Then List1.AddItem ms(i)
Next
End With
Set re = Nothing
End Sub
'描述:直接将要筛选相同行的文件拖到这个vbs文件上即可
'作者:sysdzw
'邮箱:sysdzw@163.com
'QQ:171977759
'12:51 2009-7-12
Dim strFileSource, strFileResult,t1
On Error Resume Next
strFileSource = wscript.Arguments(0)
strFileResult = Left(strFileSource, InStrRev(strFileSource, ".") - 1) & "_out.txt"
If strFileSource <> "" Then
t1=Time()
Set fso = CreateObject("scripting.filesystemobject")
Set stream = fso.opentextfile(strFileSource, 1, False)
Set stream2 = fso.opentextfile(strFileResult, 2, True)
Set dict = CreateObject("scripting.dictionary")
While Not stream.atendofstream
Line = stream.readline
If Not dict.Exists(Line) Then
Call dict.Add(Line, Null)
Call stream2.writeline(Line)
End If
Wend
stream.Close
stream2.Close
MsgBox "处理完毕!总计耗时 " & DateDiff("s",t1,Time) & " 秒。" & vbCrLf & vbCrLf & strFileResult, vbInformation, "Del Same Line QQ:171977759"
Else
MsgBox "no file!", vbExclamation, "Del Same Line QQ:171977759"
End If