Mega Code Archive

 
Categories / VB.Net Tutorial / Regular Expressions
 

Regular expression using character class

Imports System.Text.RegularExpressions Module Example    Public Sub Main()       Dim pattern1 As String = "\bgr[ae]y\b"       Dim input As String = "The gray wolf blended in among the grey rocks."       For Each match As Match In Regex.Matches(input, pattern1)          Console.WriteLine("'{0}' found at position {1}", _                            match.Value, match.Index)       Next               End Sub End Module