Dim SubMatch as Match = Match.Empty 'Initialize, in case it's not set in the loop below Dim Line as String For Each Line in EmailHeaderLines 'If this is the subject, save the match info for later . . . Dim ThisMatch as Match = Regex.Match(Line, "^Subject:\s*(.*)", _ RegexOptions.IgnoreCase) If ThisMatch.Success SubMatch = ThisMatch End If Next If SubMatch.Success Console.WriteLine(SubMatch.Result("The subject is: $1")) Else Console.WriteLine("No subject!") End If ----------------------------------------------------------------------------- Copyright 1997-2024 Jeffrey Friedl