VB.Net |使用子字符串

时间:2017-05-10 21:02:06

标签: vb.net

我目前在编写程序时遇到困难,该程序从正在处理的Web源检索网站URL(例如,在该特定网页中查找以“http://www.bbc.co.uk”开头的所有URL。)

我目前的代码是:

 Dim sourceString As String                                    'web page source
 Dim searchSite As String = webAddressesSource(s)              'site to search

      ''trawls each character of websource with the length of the website + 10
        For n = 0 To sourceString.Length - searchSite.Length - 10

            If sourceString.Substring(n, searchSite.Length) = searchSite Then
                lstOutput.Items.Add(sourceString.Substring(n, searchSite.Length + (10)))
            End If

        Next n

因此,此代码将输出所有与搜索网站相同的网站链接,以及“searchSite”结尾后的10个字符,例如。 'http://www.bbc.co.uk##########'

输出如下字符串:

http://www.bbc.co.uk/tv/">TV</
http://www.bbc.co.uk/radio/">R
http://www.bbc.co.uk/food/">Fo

但是,我需要获得如下链接输出:

http://www.bbc.co.uk/tv/    
http://www.bbc.co.uk/radio/
http://www.bbc.co.uk/food/

非常感谢有关如何实现这一目标的任何帮助或想法。

0 个答案:

没有答案