太复杂了,目测sed无能为力,下面给出vbs解:- Dim objFSO, Rstr, Arr, Wstr
- Set objFSO = CreateObject("Scripting.FileSystemObject")
- Rstr = objFSO.OpenTextFile("a.txt").ReadAll
- Arr = Split(Rstr, vbCrLf)
- For Each str In Arr
- If InStr(1, str, "@gmail.com", 1) Then GetMail(str)
- Next
- objFSO.OpenTextFile("new.txt", 2, True).Write Wstr
- Set objFSO = Nothing
- CreateObject("Wscript.Shell").Run "cmd /cstart new.txt", True, True
-
- Function GetMail(Str)
- Dim objReg
- Set objReg = New RegExp
- objReg.Global = True
- objReg.IgnoreCase = True
- objReg.Pattern = "[\s]*.*?\(*([^\(]+@gmail.com).*"
- Wstr = Wstr & objReg.Replace(Str, "$1") & vbCrLf
- End Function
复制代码
|