| Text = readTextFile("1.txt") | | Text = reReplace(Text,"\|.*",vbCrLf) | | writeTextFile Text,"2.txt" | | | | | | Function readTextFile(Path) | | Dim fso,ts | | Set fso = CreateObject("Scripting.Filesystemobject") | | Set ts = fso.OpenTextFile(Path,1) | | readTextFile = ts.ReadAll | | ts.Close | | End Function | | | | Function writeTextFile(Text,Path) | | Dim fso,ts | | Set fso = CreateObject("Scripting.Filesystemobject") | | Set ts = fso.CreateTextFile(Path,True) | | ts.Write Text | | ts.Close | | End Function | | | | Function reReplace(string1,Pattern,string2) | | Set re = New RegExp | | re.Pattern = Pattern | | re.Global = True | | re.IgnoreCase = True | | re.MultiLine = True | | reReplace = re.Replace(string1,string2) | | End FunctionCOPY |
sed 更方便:@sed "s/|.*//" 1.txt >2.txtCOPY
|