0

如何将行的开头与关键字“dog”匹配,结尾是等号我没有工作

Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
    Dim iString As String = "cats=123" & vbCrLf & "dog=456"
    Dim q1 = System.Text.RegularExpressions.Regex.Match(iString, "^dog=")
    If q1.Success Then
        Debug.Print("found")
    Else
        Debug.Print("not found")
    End If
End Sub
4

1 回答 1

1

你几乎没问题,你只需要一个选项来将输入视为多行:

Dim q1 = System.Text.RegularExpressions.Regex.Match(iString, "^dog=", RegexOptions.Multiline)
于 2013-10-07T01:06:39.647 回答