为什么regex.matches找不到存在的东西

时间:2016-10-18 09:09:06

标签: xml vb.net

有人可以帮助我吗?

我的代码:

    Private Sub setDeny(ByVal text As String)
    Dim pattern As String = "(?<=<DeniedWebsiteList>)(.*)(?=</DeniedWebsiteList>)"
    Dim m1 As MatchCollection = Regex.Matches(text, pattern)
    pattern = "(?<=<Website>)(.*)(?=</Website>)"
    Dim m2 As MatchCollection = Regex.Matches(m1(0).ToString, pattern)

    For Each website In m2
        deniedWebsiteList.Add(website.ToString)
    Next
End Sub

文本值是这个xml文件:

<?xml version="1.0" ?>
<Config>

  <DeniedWebsiteList>
    <Website>
      sapo.pt
    </Website>
    <Website>
      facebook.com
    </Website>
  </DeniedWebsiteList>
</Config>

当我运行代码时在文本上找不到任何模式。

0 个答案:

没有答案