QTP Script to Count Number of Times a Word Appears in a Text File-VB Script to Count Number of Times a Word Appears in a Text File


QTP Script to Count Number of Times a Word Appears in a Text File



Const ForReading = 1



Set fso = CreateObject( "Scripting.FileSystemObject" )



Set textFile = fso.OpenTextFile( "C:\qtp.txt", ForReading )



contents = textFile.ReadAll



textFile.Close



Set rgxp = New Regexp



rgxp.Pattern = "QTP"



rgxp.IgnoreCase = True



rgxp.Global = True



Set matches = rgxp.Execute( contents )



Msgbox "Count = " & matches.Count

No comments:

Related Posts Plugin for WordPress, Blogger...

Fun and Knowledge