first read the text in, line by line.
for each line check the first 10th chars. If they are not an “invalid char” (tab or space) include the line in the final string. Then store the final string. (you can overwrite the original file if needed)
List<char> invalidChars = new List<char> {" ", ";"};
string finalString = "";
using (StreamReader sr = new StreamReader("TestFile.txt"))
{
//grab line
String line = sr.ReadToEnd();
//grab first 10 chars of the line
string firstChars = line.substring(0,10);
//check if contains
bool hasInvalidChars = false;
foreach(char c in invalidChars)
{
if(firstChars.toLowerInvariant().IndexOf(c) == 1)
hasInvalidChars = true;
}
if(!hasInvalidChars)
finalString += line + Environment.NewLine;
}
//now store results
using (System.IO.StreamWriter file =
new System.IO.StreamWriter(@"results.txt"))
{
file.write(finalString);
}
then break the line into pieces: