vb.net查找字符串中包含的行

vb.net查找字符串中包含的行,vb.net,contains,webresponse,Vb.net,Contains,Webresponse,如果我能在文件中找到包含word的行 File.ReadAllLines(html).FirstOrDefault(Function(x) x.Contains("something")) 如何查找字符串中包含的所有行 例如,我做了一个webresponse Dim rt As String = "http://www.somesaite.com" Dim wRequest As WebRequest Dim WResponse As WebResponse D

如果我能在文件中找到包含word的行

File.ReadAllLines(html).FirstOrDefault(Function(x) x.Contains("something"))
如何查找字符串中包含的所有行 例如,我做了一个webresponse

    Dim rt As String = "http://www.somesaite.com"
    Dim wRequest As WebRequest
    Dim WResponse As WebResponse
    Dim SR As StreamReader
    wRequest = FtpWebRequest.Create(rt)
    WResponse = wRequest.GetResponse
    SR = New StreamReader(WResponse.GetResponseStream)
    rt = SR.ReadToEnd

如何查找包含在
rt
中的行?

您可以阅读
StreamReader
提供给您的所有文本,然后可以按
环境分割这些文本。换行符
字符。然后您应该能够使用您第一次提到的lambda表达式(因为
File.ReadAllLines()
方法返回一个字符串数组)


您可以阅读
StreamReader
提供给您的所有文本,然后可以按
Environment.NewLine
字符分割这些文本。然后您应该能够使用您第一次提到的lambda表达式(因为
File.ReadAllLines()
方法返回一个字符串数组)


通过使用循环和
SR.ReadLine()
逐行读取,或者将整个文本拆分为如下数组:
Dim arr()As String=SR.ReadToEnd().split(Environment.NewLine)
@visualincent您的意思是将整个html代码逐行拆分为arry,然后对每个Str使用
作为arr中的字符串,如果Str.Contains(“某物”)
???不,将其拆分为一个数组,并在该数组上调用
.FirstOrDefault(函数(x)x.Contains(“某物”)
File.ReadAllLines()
返回一个字符串数组。是的,给我几分钟我的答案对我来说很有用…可以使用循环和
SR.ReadLine()
逐行读取,或者将整个文本拆分为如下数组:
Dim arr()As string=SR.ReadToEnd().split(Environment.NewLine)
@visualvent您的意思是将整个html代码逐行拆分为arry,然后将
作为arr中的字符串用于每个Str,如果Str.Contains(“某物”)
???否,将其拆分为一个数组,并在该数组上调用
.FirstOrDefault(函数(x)x.Contains(“某物”)
File.ReadAllLines()
返回一个字符串数组。是的,给我几分钟时间我的答案对我有用。。。
Dim FoundLine As String = SR.ReadToEnd().Split(Environment.NewLine).FirstOrDefault(Function(x) x.Contains("something"))