cra*_*les 4 regex vb.net string search
我将网页的源代码保存在文本框中,我想搜索文本框并将来自该网站自己的域(www.test.com)的所有链接放入字符串列表中。
例子:
文本框在源代码中隐藏了以下链接
a href="index.html
a href="www.test.com/about_us.html
a href="mailto:test@test.com
a href="www.google.com/partners.html
我想提取 index.html 和 about_us.html 并将它们放入字符串列表中。
我试过了:
    For Each i As Match In Regex.Matches(TextBox2.Text, "\b" + url + "\b")
        list1.Add(i.Value)
    Next
但似乎无法让它工作,任何帮助将不胜感激。
我最终使用了 Stephan 的答案,并从regexhero获得了我需要的代码
        Dim strRegex As String = "<?href\s*=\s*[""'].+?[""'][^>]*?"
        Dim myRegex As New Regex(strRegex, RegexOptions.None)
        For Each myMatch As Match In myRegex.Matches(TextBox1.Text)
            If myMatch.Success Then
                ' Add your code here
            End If
        Next
| 归档时间: | 
 | 
| 查看次数: | 3842 次 | 
| 最近记录: |