0

我想得到下一个第一行,后跟字符串“已发布”。这是我的代码:

Dim builder As New StringBuilder()
Dim reader As New StringReader(txtOCR.Text)
While True
    Dim line As String = reader.ReadLine()
    If line Is Nothing Then Exit While
    If Not line.ToLower().Contains("published") Then
        builder.AppendLine(line)
    End If
End While
txtOCR.Text = builder.ToString()

此代码获取所有行后跟字符串“已发布”,但我只想获取下第一行..

4

1 回答 1

1

如果您想要包含“已发布”一词的行之后的行:

Dim found as Boolean = False
Dim line as String = reader.ReadLine()
While Not line is Nothing
    If Found Then
        builder.AppendLine(line)
        Exit While
    End If
    If line.ToLower().Contains("published") Then
        Found = True
    End If
    line = reader.ReadLine()
End While

请原谅任何语法错误。我对VB不是很流利。

于 2013-02-28T04:06:15.180 回答