【发布时间】:2015-05-30 13:41:12
【问题描述】:
我有如下文本文件:
some text 402115000518432
402115000518432 97517518878 IDLE
some text
...
some text 402115001509990
402115001509990 97517490827 IDLE
...
我想要在 excel 文件中以 40211“开始”的整行。期望的输出:
402115000518432 97517518878 IDLE
402115001509990 97517490827 IDLE
我正在尝试使用以下代码:
Dim pattern = "(?<=\s*)40211[^\s]*"
Dim i = 1
For Each line In File.ReadLines(RichTextBox1.Text)
Dim match = Regex.Match(line, pattern)
If match.Success Then
sheet.Cells(i, 1).Value = match.Value
i += 1
End If
Next
但输出只是以 40211 开头的值,而不是以 40211 开头的整行。感谢任何帮助。
【问题讨论】: