Option Explicit On ' These are not specifically required to use regexes, Option Strict On ' but their use is good general practice. ' Make regex-related classes easily available. Imports System.Text.RegularExpressions Module SimpleTest Sub Main() Dim SampleText as String = "this is the 1st test string" Dim R as Regex = New Regex("\d+\w+") 'Compile the pattern. Dim M as Match = R.match(SampleText) 'Check against a string. If not M.Success Console.WriteLine("no match") Else Dim MatchedText as String = M.Value 'Query the results . . . Dim MatchedFrom as Integer = M.Index Dim MatchedLen as Integer = M.Length Console.WriteLine("matched [" & MatchedText & "]" & _ " from char#" & MatchedFrom.ToString() & _ " for " & MatchedLen.ToString() & " chars.") End If End Sub End Module ----------------------------------------------------------------------------- Copyright 1997-2024 Jeffrey Friedl