' VB Script Document
option explicit
Dim objRegExpr
Set objRegExpr = New regexp
Dim InputFileName, OutputFileName, Result
objRegExpr.Pattern = InputBox("Regex String :","RegEx","CUSTOMER
TOTAL\s+=\s+[0-9\.]+")
if ( objRegExpr.Pattern <> "" ) then ' for cancel.
InputFileName = InputBox("Input file path and name :","Input
File","y:\fix\roc\dated.txt")
if ( InputFileName <> "" ) then ' for cancel.
OutputFileName = InputBox("Output file path and name :","Output
File","Regex.txt")
if ( OutputFileName <> "" ) then ' for cancel.
if ( MsgBox ( "Process file?", vbOKCancel, "Process") = vbOK ) then
objRegExpr.Global = True
objRegExpr.IgnoreCase = True
Dim colMatches
Dim objMatch
Dim RetStr
Dim objFSO,objFileRead,objFileWrite,strLine
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objFileRead = objFSO.OpenTextFile(InputFileName, 1, false)
Set objFileWrite = objFSO.CreateTextFile(OutputFileName)
Do While objFileRead.AtEndOfStream = False
strLine = objFileRead.ReadLine
Set colMatches = objRegExpr.Execute(strLine)
For Each objMatch In colMatches ' Iterate Matches collection.
objFileWrite.WriteLine(objMatch.Value)
Next
Loop
end if
end if
end if
end if
Wscript.Echo "Regex Done"