Login | |
|
 |
RE: finding multiple strings in a file - 4/28/2008 1:43:49 AM
|
|
 |
|
| |
ebgreen
Posts: 4595
Score: 29
Joined: 7/12/2005
Status: offline
|
If all you want is counts, you don't need to loop at all. Look at this example: Dim oFSO : Set oFSO = CreateObject("Scripting.FileSystemObject") strFile = oFSO.OpenTextFile("C:\Test.txt").ReadAll() Dim oRE : Set oRE = New Regexp oRE.Global = True oRE.Pattern = "Eric" Set colMatches = oRE.Execute(strFile) WScript.Echo "Eric = " & colMatches.Count
_____________________________
"... when you are good and crazy, oooh, oooh, oooh, the sky is the limit!" - The Tick Goog places to start:http://www.visualbasicscript.com/m_24727/tm.htm http://www.visualbasicscript.com/m_47117/tm.htm
|
|
| |
|
|
|
 |
RE: finding multiple strings in a file - 4/28/2008 1:53:07 AM
|
|
 |
|
| |
ebgreen
Posts: 4595
Score: 29
Joined: 7/12/2005
Status: offline
|
Make an array of the names: arrNames = Array("Eric", "Dave", ...) Then Loop through the array checking for each name: For Each strName In arrNames oRE.Pattern = strName . . . WScript.Echo strName & " = " & colMatches.Count Next
_____________________________
"... when you are good and crazy, oooh, oooh, oooh, the sky is the limit!" - The Tick Goog places to start:http://www.visualbasicscript.com/m_24727/tm.htm http://www.visualbasicscript.com/m_47117/tm.htm
|
|
| |
|
|
|
|
|