有一个名为abc.log
的日志文件,它包含许多行,如下所示:
Line 8123: Feb 01 19:44:40.961 | INFO | JEZHckpTehtA-ADSW4T14T5 | PROD | 10.86.99.108 | Feb 01 2016 19:44:29.595 | EVNT=SWIdmst|DQLN=YN| DQLN=EQUAL_QUAL_QUEUE_GOHEAD_IT
Line 8124: Feb 01 19:44:40.961 | INFO | JEZHckpTehtA-ADSW4T14T5 | PROD | 10.86.99.108 | Feb 01 2016 19:44:29.595 | EVNT=SWIdmst|DQLN=op.....
Line 8127: Feb 01 19:44:40.961 | INFO | JEZHckpTehtA-ADSW4T14T5 | PROD | 10.86.99.108 | Feb 01 2016 19:44:29.595 | EVNT=SWIdmst|DQLN=YN...........
Line 8129: Feb 01 19:44:40.961 | INFO | JEZHckpTehtA-ADSW4T14T5 | PROD | 10.86.99.108 | Feb 01 2016 19:44:29.595 | EVNT=SWIdmst|DQLN=YN| DQLN=Other_number
Line 8145: Feb 01 19:44:40.961 | INFO | JEZHckpTehtA-ADSW4T14T5 | PROD | 10.86.99.108 | Feb 01 2016 19:44:29.595 | EVNT=SWIdmst|DQLN=YN| Name=QID|Inputs=collname[allNum=12457845,oon=6842703020]|Outputid=00a4028a87c4473f,amid=2353.6,TransactionTime=125ms........
Line 8198: Feb 01 19:44:40.961 | INFO | JEZHckpTehtA-ADSW4T14T5 | PROD | 10.86.99.108 | Feb 01 2016 19:44:29.595 | End.....
我需要在所有行中搜索QUAL_QUEUE_GOHEAD_IT
并获取其ID JEZHckpTehtA-ADSW4T14T5
。然后在所有行中搜索该ID,如果在以此ID开头的行中找到DQLN=Other_number
,并且在具有相同ID的任何行中都存在EOT_Dealer_PullAHead_ETQ
,则
将同一id中存在的RuleName=GetPayoffInfo|Inputs=[accountNu.....
行提取到另一个记事本。
我有以下代码,它创建了一个新的文本板,但它没有任何内容,它显示nomatch
但日志文件包含代码中提到的所有字符串。
Const ForReading = 1
Set objFSO = CreateObject("Scripting.FileSystemObject")
'create a new text file
Set word_found1 = objFSO.CreateTextFile("C:\Users\hara\Desktop\tq\abc.log", True)
Set objFileToRead = objFSO.OpenTextFile _
("C:\Users\hara\Desktop\tq\testt1.txt", ForReading)
Do Until objFileToRead.AtEndOfStream
strFileText = objFileToRead.ReadLine
Set re = New RegExp
re.Pattern = "INFO \| ([^\|]*) \|.*QUAL_QUEUE_GOHEAD_IT"
re.Global = True
Set matches = re.Execute(strFileText)
If matches.Count > 0 Then
msg = "Found " & matches.Count & " matches:" & vbCRLF
For Each match In Matches
varid = match.SubMatches(0)
Next
word_found1.WriteLine strFileText
Else
MsgBox "No match", 0, "VBScript Regular Expression Tester"
End If
Loop
objFileToRead.Close