Permalink
Cannot retrieve contributors at this time
Fetching contributors…
| ' Visual Basic .NET Document | |
| Option Strict On | |
| Option Infer On | |
| ' <Snippet9> | |
| Imports System.Text.RegularExpressions | |
| Module Example | |
| Public Sub Main() | |
| Dim input As String = "This is one sentence. This is another." | |
| Dim pattern As String = "\b(?:\w+[;,]?\s?)+[.?!]" | |
| For Each match As Match In Regex.Matches(input, pattern) | |
| Console.WriteLine("Match: '{0}' at index {1}.", | |
| match.Value, match.Index) | |
| Dim grpCtr As Integer = 0 | |
| For Each grp As Group In match.Groups | |
| Console.WriteLine(" Group {0}: '{1}' at index {2}.", | |
| grpCtr, grp.Value, grp.Index) | |
| Dim capCtr As Integer = 0 | |
| For Each cap As Capture In grp.Captures | |
| Console.WriteLine(" Capture {0}: '{1}' at {2}.", | |
| capCtr, cap.Value, cap.Index) | |
| capCtr += 1 | |
| Next | |
| grpCtr += 1 | |
| Next | |
| Console.WriteLine() | |
| Next | |
| End Sub | |
| End Module | |
| ' The example displays the following output: | |
| ' Match: 'This is one sentence.' at index 0. | |
| ' Group 0: 'This is one sentence.' at index 0. | |
| ' Capture 0: 'This is one sentence.' at 0. | |
| ' | |
| ' Match: 'This is another.' at index 22. | |
| ' Group 0: 'This is another.' at index 22. | |
| ' Capture 0: 'This is another.' at 22. | |
| ' </Snippet9> |