读取文本文件时如何在每行中找到的最后一个数字之后跳到下一行?

How to skip to next line after the last number found in each line when reading a text file?

我的文本文件看起来像这样:

1    2   3      test//test
4    5   6    dummy//dummy

如何读取此文件并仅处理每行中出现的数字?

两种方式:

  1. 来自 ignoring the rest of the line.

  2. 通过reading the complete line into a string, put the string in an output string stream,只从输出字符串流中读取前三个数字。