本文整理匯總了VB.NET中System.Text.RegularExpressions.Capture類的典型用法代碼示例。如果您正苦於以下問題:VB.NET Capture類的具體用法?VB.NET Capture怎麽用?VB.NET Capture使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
在下文中一共展示了Capture類的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的VB.NET代碼示例。
示例1: Example
' 導入命名空間
Imports System.Text.RegularExpressions
Module Example
Public Sub Main()
Dim input As String = "Yes. This dog is very friendly."
Dim pattern As String = "((\w+)[\s.])+"
For Each match As Match In Regex.Matches(input, pattern)
Console.WriteLine("Match: {0}", match.Value)
For groupCtr As Integer = 0 To match.Groups.Count - 1
Dim group As Group = match.Groups(groupCtr)
Console.WriteLine(" Group {0}: {1}", groupCtr, group.Value)
For captureCtr As Integer = 0 To group.Captures.Count - 1
Console.WriteLine(" Capture {0}: {1}", captureCtr, _
group.Captures(captureCtr).Value)
Next
Next
Next
End Sub
End Module
輸出:
Match: Yes. Group 0: Yes. Capture 0: Yes. Group 1: Yes. Capture 0: Yes. Group 2: Yes Capture 0: Yes Match: This dog is very friendly. Group 0: This dog is very friendly. Capture 0: This dog is very friendly. Group 1: friendly. Capture 0: This Capture 1: dog Capture 2: is Capture 3: very Capture 4: friendly. Group 2: friendly Capture 0: This Capture 1: dog Capture 2: is Capture 3: very Capture 4: friendly