If the entire thing is in a string split according to new line
use: StringVaraible.Split({vblf},StringSplitOptions.None)
for each item in array check for the condition if item.startswith(“PQR”)
This will be faster for you instead of looping through each line.
I looked up the syntax on filtering your array after the split and got something like this…
with text being the variable storing the long string (From line In text.Split(vblf(0)) where line.StartsWith(“PQR”))(0).ToString
or to join the array back together…
[String].Join(vblf(0),(From line In text.Split(vblf(0)) where line.StartsWith(“PQR”))).ToString
LINQ is based on IEnumerable, which executes by iterating over the collection and checking against the predicate. If the robot doesn’t add overhead, the difference should be compeltely negligible.
Note: I’m not saying to not use LINQ (I like it and use it often too), but for beginners using an explicit loop is usually easier than querying the collections.
Good to know. Reason I made that suggestion (even if it’s harder to understand) is because when dealing with thousands of lines you kind of need a method that can drop the amount of lines down very quickly rather than having it loop for a long time.
As someone fairly new to LINQ myself, I find these solutions useful and more fun to use also.