Permalink
Cannot retrieve contributors at this time
Fetching contributors…
| ' Visual Basic .NET Document | |
| Option Strict On | |
| ' <Snippet4> | |
| Imports System.Text.RegularExpressions | |
| Module Example | |
| Public Sub Main() | |
| Dim input As String = "aa1bb2cc3dd4ee5" | |
| Dim pattern As String = "\d+" | |
| Dim substitution As String = "$`" | |
| Console.WriteLine("Matches:") | |
| For Each match As Match In Regex.Matches(input, pattern) | |
| Console.WriteLine(" {0} at position {1}", match.Value, match.Index) | |
| Next | |
| Console.WriteLine("Input string: {0}", input) | |
| Console.WriteLine("Output string: " + _ | |
| Regex.Replace(input, pattern, substitution)) | |
| End Sub | |
| End Module | |
| ' The example displays the following output: | |
| ' Matches: | |
| ' 1 at position 2 | |
| ' 2 at position 5 | |
| ' 3 at position 8 | |
| ' 4 at position 11 | |
| ' 5 at position 14 | |
| ' Input string: aa1bb2cc3dd4ee5 | |
| ' Output string: aaaabbaa1bbccaa1bb2ccddaa1bb2cc3ddeeaa1bb2cc3dd4ee | |
| ' </Snippet4> |