我的数据库中有一堆网页内容,链接如下:
Link
Guid唯一标识符是同一数据库中另一个页面的ID .
我想抓取这些页面并检查链接是否损坏.
为此,我需要一个可以返回页面上所有Guid列表的函数:
Function FindGuids(ByVal Text As String) As Collections.Generic.List(Of Guid) ... End Function
我认为这是正则表达式的工作.但是,我不知道语法.
[0-9A-F] {8} - [0-9A-F] {4} - [0-9A-F] {4} - [0-9A-F] {4} - [0-9A-F ] {12}
Function FindGuids(ByVal Text As String) As List(Of Guid) Dim Guids As New List(Of Guid) Dim Pattern As String = "[a-fA-F0-9]{8}-([a-fA-F0-9]{4}-){3}[a-fA-F0-9]{12}" For Each m As Match In Regex.Matches(Text, Pattern) Guids.Add(New Guid(m.Value)) Next Return Guids End Function