|
Mr_Ying 发表于 2015-3-16 21:30
第一行的发信人,实际上第一行都是标题。
Re: 【推荐】 westlake 托特纳姆热刺 VS 埃弗顿 , 发信人: Ai ... - Sub test()
- Open ThisWorkbook.Path & "\合并源结果.txt" For Input As #1
- s = StrConv(InputB(LOF(1), #1), vbUnicode)
- Close #1
- Set regx = CreateObject("vbscript.regexp")
- regx.Pattern = "发信人:\s*([\w-]+)(?:(?!^--)[\s\S])+^--[\s\S]+?\[FROM:\s*([\d.*]+)"
- regx.Global = True
- regx.MultiLine = True
- Set mh = regx.Execute(s)
- ReDim arr(1 To mh.Count, 1 To 2)
- For Each k In mh
- n = n + 1
- arr(n, 1) = k.submatches(0)
- arr(n, 2) = k.submatches(1)
- Next
- Range("a1").Resize(n, 2) = arr
- End Sub
复制代码 |
|