So I'm currently working on a program that reads a large txt file line by line as strings. For a particular section of the file the format is like this:
text1 : text2 : text3 : text4 : text5 : text6
I know how to split the string and find different counts.
What I want to do is check that the text in text5 starts with a certain expression SORT, and then for that line print text3.
foreach (string str in File.ReadLines(@"/filelocation"))
{
if (str.StartsWith("fusedef"))
{
string text3 = str.Split(':')[2];
string text5 = str.Split(':')[4];
if (text5.StartsWith("SORT_"))
{
Console.WriteLine(text3);
}
}
(As far as I know, counting a split string starts at 0 but correct me if I'm wrong, only started c# a few weeks ago. Thanks!)