ajtsystems
IS-IT--Management
Can anyone help me with the script below to search only for he regular expression and still only return the 1st 2 entries on the dictionary?
Dim oFSO, oTSIn, oDict, iCtr, iKey
searchstring = "Somestring"
Set objRegEx = CreateObject("VBScript.RegExp")
objRegEx.Pattern = "^25-09-2007 Somestring"
Set oFSO = CreateObject("Scripting.FileSystemObject")
Dim arrFileLines()
i = 0
Set oTSIn = oFSO.OpenTextFile("c:\scripts\test.txt",1)
Set oDict = CreateObject("Scripting.Dictionary")
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objFile = objFSO.OpenTextFile("C:\Scripts\Test.txt", 1)
Set objFile1 = objFSO.OpenTextFile("C:\Scripts\results.txt", 2)
'check through text file and create 1d array
Do
oDict.Add iCtr, oTSIn.ReadLine
iCtr = iCtr + 1
Loop Until oTSIn.AtEndOfStream
' Echo header lines first
WScript.Echo oDict.Item(0)
WScript.Echo oDict.Item(1)
'if echo = instr then ok
I thinnkmaybe the code goes here...
objFile1.Close
Dim oFSO, oTSIn, oDict, iCtr, iKey
searchstring = "Somestring"
Set objRegEx = CreateObject("VBScript.RegExp")
objRegEx.Pattern = "^25-09-2007 Somestring"
Set oFSO = CreateObject("Scripting.FileSystemObject")
Dim arrFileLines()
i = 0
Set oTSIn = oFSO.OpenTextFile("c:\scripts\test.txt",1)
Set oDict = CreateObject("Scripting.Dictionary")
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objFile = objFSO.OpenTextFile("C:\Scripts\Test.txt", 1)
Set objFile1 = objFSO.OpenTextFile("C:\Scripts\results.txt", 2)
'check through text file and create 1d array
Do
oDict.Add iCtr, oTSIn.ReadLine
iCtr = iCtr + 1
Loop Until oTSIn.AtEndOfStream
' Echo header lines first
WScript.Echo oDict.Item(0)
WScript.Echo oDict.Item(1)
'if echo = instr then ok
I thinnkmaybe the code goes here...
objFile1.Close