Imports System.Collections.Generic
Private Delegate Function Transform(ByVal value As String) As String
Private ReadOnly _transformations As New Dictionary(Of String, Transform)
IO.File.WriteAllLines("test.txt", {"bob is cool", "john is cooler", "nothing in here matches"})
_transformations.Add("bob", Function(value) value.Replace("bob", "ray"))
_transformations.Add("john", Function(value) value.Replace("john", "jane"))
Dim strOutput As New StringBuilder()
Dim lines() As String = IO.File.ReadAllLines("test.txt")
Dim transformation = _transformations.FirstOrDefault(Function(t) line.Contains(t.Key))
If (Not String.IsNullOrWhitespace(transformation.Key)) Then
strOutput.AppendLine(transformation.Value(line))
strOutput.AppendLine(line)
Console.WriteLine(strOutput)