回复 7# pan528
x_xxx_ 由数字和下划线组成- Set fso = CreateObject("Scripting.FileSystemObject")
- Set dic = CreateObject("Scripting.Dictionary")
- Set file = fso.OpenTextFile("a.txt")
-
- Do until file.AtEndOfStream
- str = file.ReadLine
- a = RegEx(str)
- If str <> a Then
- If not dic.Exists(a) Then
- dic.Add a,str
- Else dic.Item(a) = dic.Item(a) & vbCrLf & str
- End If
- End If
- Loop
-
- For Each b in dic.Keys
- If InStr(dic.Item(b),vbCrLf) Then
- fso.OpenTextFile("b.txt",8,True).WriteLine dic.Item(b)
- End If
- Next
-
- Function RegEx(str)
- Set re = New RegExp
- re.Pattern = "^\s*((\d+_)+).*$"
- RegEx = re.Replace(str,"$1")
- End Function
复制代码
|