本文整理汇总了VB.NET中System.Text.RegularExpressions.GroupCollection.Item属性的典型用法代码示例。如果您正苦于以下问题:VB.NET GroupCollection.Item属性的具体用法?VB.NET GroupCollection.Item怎么用?VB.NET GroupCollection.Item使用的例子?那么恭喜您, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在类System.Text.RegularExpressions.GroupCollection 的用法示例。
在下文中一共展示了GroupCollection.Item属性的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的VB.NET代码示例。
示例1: Example
' 导入命名空间
Imports System.Text.RegularExpressions
Module Example
Public Sub Main()
Dim pattern As String = "(\d+)*(\w)\2"
Dim input As String = "AA"
Dim match As Match = Regex.Match(input, pattern)
' Get the first named group.
Dim group1 As Group = match.Groups.Item(1)
Console.WriteLine("Group 1 value: {0}", If(group1.Success, group1.Value, "Empty"))
' Get the second named group.
Dim group2 As Group = match.Groups.Item(2)
Console.WriteLine("Group 2 value: {0}", If(group2.Success, group2.Value, "Empty"))
' Get a non-existent group.
Dim group3 As Group = match.Groups.Item(3)
Console.WriteLine("Group 3 value: {0}", If(group3.Success, group3.Value, "Empty"))
End Sub
End Module
开发者ID:VB.NET开发者,项目名称:System.Text.RegularExpressions,代码行数:22,代码来源:GroupCollection.Item 输出:
Group 1 value: Empty
Group 2 value: A
Group 3 value: Empty
示例2: Example
' 导入命名空间
Imports System.Text.RegularExpressions
Module Example
Public Sub Main()
Dim pattern As String = "(?<numbers>\d+)*(?<letter>\w)\k<letter>"
Dim input As String = "AA"
Dim match As Match = Regex.Match(input, pattern)
' Get the first named group.
Dim group1 As Group = match.Groups.Item("numbers")
Console.WriteLine("Group 'numbers' value: {0}", If(group1.Success, group1.Value, "Empty"))
' Get the second named group.
Dim group2 As Group = match.Groups.Item("letter")
Console.WriteLine("Group 'letter' value: {0}", If(group2.Success, group2.Value, "Empty"))
' Get a non-existent group.
Dim group3 As Group = match.Groups.Item("none")
Console.WriteLine("Group 'none' value: {0}", If(group3.Success, group3.Value, "Empty"))
End Sub
End Module
开发者ID:VB.NET开发者,项目名称:System.Text.RegularExpressions,代码行数:22,代码来源:GroupCollection.Item 输出:
Group 'numbers' value: Empty
Group 'letter' value: A
Group 'none' value: Empty
注:本文中的System.Text.RegularExpressions.GroupCollection.Item属性示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论