【发布时间】:2017-04-11 17:28:32
【问题描述】:
我知道如何打印每个第 n 行和第 n 个匹配行,但不知道如何打印每个匹配行和所有非数学行。
输入示例:
Something else 1
Downloading: file1 1%
Downloading: file1 10%
Something else 2
Downloading: file1 30%
Something else 3
Downloading: file1 40%
Downloading: file2 50%
Downloading: file1 60%
Downloading: file1 100%
Downloading: file2 100%
Something else 4
如果模式是 '^Downloading:' 并打印每个匹配的第二行,输出应该是这样的:
Something else 1
Downloading: file1 10%
Something else 2
Something else 3
Downloading: file1 40%
Downloading: file1 60%
Downloading: file2 100%
Something else 4
【问题讨论】:
-
显示输入片段和预期输出