Imports System
Imports System.Text.RegularExpressions
' b[aeou]y: This pattern looks for strings that match the following:
' b: The letter "b".
' [aeou]: Any single character that is either "a", "e", "o", or "u".
' y: The letter "y".
Public Class Program
Public Shared Function CheckPattern(ByVal pattern As String, ByVal text As String) As Boolean
Dim re As Regex = New Regex(pattern, RegexOptions.IgnoreCase)
Return re.IsMatch(text)
End Function
Public Shared Sub Main()
Dim pattern As String = "b[aeou]y"
Console.WriteLine(CheckPattern(pattern, "A smart boy"))
Console.WriteLine(CheckPattern(pattern, "I want to buy this laptop"))
Console.WriteLine(CheckPattern(pattern, "baay"))
Console.WriteLine(CheckPattern(pattern, "baeouy"))
Console.WriteLine(CheckPattern(pattern, "baey"))
Console.WriteLine(CheckPattern(pattern, "This is beauty"))
Console.WriteLine(CheckPattern(pattern, "A programming book"))
End Sub
End Class
' run:
'
' True
' True
' False
' False
' False
' False
' False
'