Mega Code Archive

 
Categories / VB.Net Tutorial / Regular Expressions
 

W matches any non-word character

Imports System.Text.RegularExpressions Module Example    Public Sub Main()       Dim pattern As String = "\b(\w+)(\W){1,2}"       Dim input As String = "this is a test 123."       For Each match As Match In Regex.Matches(input, pattern)          Console.WriteLine(match.Value)          Dim captures As CaptureCollection = match.Groups(2).Captures          For ctr As Integer = 0 To captures.Count - 1              Console.WriteLine(captures(ctr).Value)              Console.WriteLine(Convert.ToUInt16(captures(ctr).Value.Chars(0)).ToString("X4"))              Console.WriteLine(If(ctr < captures.Count - 1, ", ", ""))          Next       Next    End Sub End Module