The output that i get keeps repeating.

For example,
strInput= "orange~banana~banana~apple"
but what i get is this
output= "orange~orange banana~orange banana banana~orange banana banana apple"

I'm pretty sure my regex is right. Any help would be much appreciated. Thanks!

 using (StreamWriter write = new StreamWriter(filePath, true))
 {

string[] line = strInput.Split('~');
foreach (string part in line)
{

 MatchCollection matches1 = Regex.Matches(part, @"\d{2}\\");
 string range = matches1[0].Value;
 switch (range)
 {
     case "00\\":
     strFruitType += "Apple";
     break;
     case "01\\":
     strFruitType += "Orange";
     break;
     case "02\\":
     strFuitType += "Banana";
     break;
}

write.WriteLine(strFruitType+"~");

                                            }

                                        }

what is your expected output?

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.