本文整理匯總了VB.NET中System.Text.RegularExpressions.MatchCollection.Count屬性的典型用法代碼示例。如果您正苦於以下問題:VB.NET MatchCollection.Count屬性的具體用法?VB.NET MatchCollection.Count怎麽用?VB.NET MatchCollection.Count使用的例子?那麽, 這裏精選的屬性代碼示例或許可以為您提供幫助。您也可以進一步了解該屬性所在類System.Text.RegularExpressions.MatchCollection
的用法示例。
在下文中一共展示了MatchCollection.Count屬性的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的VB.NET代碼示例。
示例1: Example
' 導入命名空間
Imports System.Text.RegularExpressions
Module Example
Public Sub Main()
Dim pattern As String = "\d+"
Dim inputs() As String = { "This sentence contains no numbers.",
"123 What do I see?",
"2468 369 48 5" }
For Each inputStr In inputs
Dim matches As MatchCollection = Regex.Matches(inputStr, pattern)
Console.WriteLine("Input: {0}", inputStr)
If matches.Count = 0
Console.WriteLine(" No matches")
Else
For Each m As Match In matches
Console.WriteLine(" {0} at index {1}", m.Value, m.Index)
Next
End If
Console.WriteLine()
Next
End Sub
End Module
輸出:
Input: This sentence contains no numbers. No matches Input: 123 What do I see? 123 at index 0 Input: 2468 369 48 5 2468 at index 0 369 at index 5 48 at index 9 5 at index 12