What is the best approach to scan a file if you are looking for more than one pattern. Lets say you have a text file "example.txt", and you want to search for an array of strings {"error", "warning", "failed"} within the file. What is an efficient way of doing this?
Geek-Master
Recommended Answers
Jump to PostHi,
Dim aStreamReader As System.IO.StreamReader = New System.IO.StreamReader("file.txt")
For Each s As String In aStreamReader.ReadToEnd().Split(" ")
'Process your space delimited tokens here
'Split() accepts more than one deimiter as an array if you need
NextOr you can use aStreamReader.ReadToEnd().Split(" ").IndexOf(.....) iteratively if you don't want to process …
All 4 Replies
Lord Soth 4 Posting Whiz in Training
Geek-Master
jerMAn 0 Light Poster
Lord Soth 4 Posting Whiz in Training
Be a part of the DaniWeb community
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.