Originally Posted By: apronk
Richard: I totally agree with you, however this scriplet is not designed with a fullfledged search function in mind, just to quickly and nasty do what it is supposed to \:\)


Well, you can do it quicker, nastier and get more accurate results ;\)

 Code:
$sFile="test.txt"
$oFSO=CreateObject("Scripting.FileSystemObject")
$oFile=$oFSO.OpenTextFile($sFile, 1, -1)
 
$sFileData=@CRLF+$oFile.ReadAll
 
"File content:"
$sFileData+@CRLF
 
"The word 'foobar' appears "+UBound(Split($sFileData,"foobar"))+" times in the file"+@CRLF
"The word 'grape' appears "+UBound(Split($sFileData,"grape"))+" times in the file"+@CRLF
"The word 'grape' appears on its own on "+UBound(Split($sFileData,@CRLF+"grape"+@CRLF))+" lines in the file"+@CRLF
"The letter 'r' appears "+UBound(Split($sFileData,"r"))+" times in the file"+@CRLF
 
exit 0


When run with a small test file these are the results:
 Quote:
D:\temp>kix32 ml.kix
File content:
Orange
Lemon
Grapefruit
Melon
Grape

The word 'foobar' appears 0 times in the file
The word 'grape' appears 2 times in the file
The word 'grape' appears on its own on 1 lines in the file
The letter 'r' appears 4 times in the file