I have a file which contains lines like the following :
Line 1: Pass 2/2 frame 5465/5749 15574295B [K51.462 50.234 55.344 56.937 210F
Line 2: Pass 2/2 frame 5452/5735 15571353B [K51.466 50.235 55.330 57.012 116F 344F
Line 3: Pass 2/2 frame 5495/5782 15593147B [K39.195 37.675 45.782 48.996 787F37.495 35.928 45.071 48.092 811F38.408 36.913 44.433 48.123 852F37.102 35.567 43.789 47.557 869F36.774 35.246 43.322 47.165 914F37.376 35.886 43.465 46.688 990F36.663 35.126 43.528 46.879 979F37.688 36.253 42.631 47.142 943F38.459 37.118 42.163 47.445 903F38.254 36.992 40.945 47.740 843F44.970 45.302 41.549 55.175 3039F41.745 40.885 41.478 53.953 613F40.146 38.934 41.952 52.936 606F39.142 38.497 37.875 55.957 389F46.844 45.352 52.002 59.382 177F
I wanna the value before the "F" char ,if line contains 2F it will sum the two values and so on ( at least I wanna skip the line that contains more than 2F )
the following code work when the line has 2F but it is not work with the third line
char[] sep = new char[] { ' ' };
while ((line = reader.ReadLine()) != null)
{
string[] items = line.Split(sep);
foreach (string item in items)
{
Match match = Regex.Match(item, @"\dF\d");
if (match.Success)
{
string[] fff = Regex.Split(item, "F");
foreach (string f in fff)
{
sw.WriteLine(f);
break;
}
}
string[] items2 =item.Split(sep);
foreach (string item2 in items2)
{
if (item2.EndsWith("F"))
{
F++;
Framesize = item2.Replace('F', ' ');
if (F == 1) temp = Convert.ToInt32(Framesize);
if (F == 2)
{
temp = temp + Convert.ToInt32(Framesize);
Framesize = temp.ToString();
flag = 1;
}
}
}//end foreach
}
if (F==1 || F==2 )
sw.WriteLine(Framesize);
F = 0;
flag = 0;
}
sw.Close();}
is there any help ???!!!!!

New Topic/Question
Reply



MultiQuote





|