本帖最后由 apang 于 2014-3-28 23:27 编辑
- Set fso = CreateObject("Scripting.FileSystemObject")
- txt = fso.OpenTextFile("b.txt").ReadAll
- Set f = fso.OpenTextFile("a.txt")
- while Not f.AtEndOfStream
- strline = Trim(f.ReadLine)
- If InStr(strLine, "、") Then
- ar = Split(strLine, "、")
- s = s & ar(0) & "、" & RegEx(ar(1)) & vbCrLf
- End If
- wend
-
- fso.OpenTextFile("c.txt", 2, true).Write s
-
- Function RegEx(str)
- Set re = New RegExp
- re.Pattern = "\b" & str & "\b[^\r]*"
- re.IgnoreCase = true
- If re.Test(txt) Then
- RegEx = re.Execute(txt)(0)
- Else RegEx = str
- End If
- End Function
复制代码
|