My suggestion:
public void ReadJustNumbers() { Regex r = new Regex(@"\d+"); using (var sr = new StreamReader("xxx")) { string line; while (null != (line=sr.ReadLine())) { foreach (Match m in r.Matches(line)) { Console.WriteLine(m.Value); } } } }
where xxx is the file name, obviously, you will use the corresponding digit in a more elegant way than resetting it to the console;)
source share