Permalink
Fetching contributors…
Cannot retrieve contributors at this time
38 lines (33 sloc) 1.05 KB
' Visual Basic .NET Document
Option Strict On
' <Snippet7>
Imports System.Text.RegularExpressions
Module Example
Public Sub Main()
Dim inputs() As String = { "aaaaa", "aaaaab" }
Dim backtrackingPattern As String = "(a+)\w"
Dim match As Match
For Each input As String In inputs
Console.WriteLine("Input: {0}", input)
match = Regex.Match(input, backtrackingPattern)
Console.WriteLine(" Pattern: {0}", backtrackingPattern)
If match.Success Then
Console.WriteLine(" Match: {0}", match.Value)
Console.WriteLine(" Group 1: {0}", match.Groups(1).Value)
Else
Console.WriteLine(" Match failed.")
End If
Next
Console.WriteLine()
End Sub
End Module
' The example displays the following output:
' Input: aaaaa
' Pattern: (a+)\w
' Match: aaaaa
' Group 1: aaaa
' Input: aaaaab
' Pattern: (a+)\w
' Match: aaaaab
' Group 1: aaaaa
' </Snippet7>