Option Explicit On Option Strict On Imports System.Text.RegularExpressions Imports System.Reflection Module BuildMyLibrary Sub Main() 'The calls to RegexCompilationInfo below provide the pattern, regex options, name within the class, 'class name, and a Boolean indicating whether the new class is public. The first class, for example, 'will be available to programs that use this assembly as "jfriedl.Mail.Subject", a Regex constructor. Dim RCInfo() as RegexCompilationInfo = { _ New RegexCompilationInfo( _ "^Subject:\s*(.*)", RegexOptions.IgnoreCase, _ "Subject", "jfriedl.Mail", true), _ New RegexCompilationInfo( _ "^From:\s*(.*)", RegexOptions.IgnoreCase, _ "From", "jfriedl.Mail", true), _ New RegexCompilationInfo( _ "\G(?:^|,) " & _ "(?: " & _ " (?# Either a double-quoted field... ) " & _ " "" (?# field's opening quote ) " & _ " (? (?> [^""]+ | """" )* ) " & _ " "" (?# field's closing quote ) " & _ " (?# ...or... ) " & _ " | " & _ " (?# ...some non-quote/non-comma text... ) " & _ " (? [^"",]* ) " & _ " )", _ RegexOptions.IgnorePatternWhitespace, _ "GetField", "jfriedl.CSV", true) _ } 'Now do the heavy lifting to build and write out the whole thing . . . Dim AN as AssemblyName = new AssemblyName() AN.Name = "JfriedlsRegexLibrary" 'This will be the DLL's filename AN.Version = New Version("1.0.0.0") Regex.CompileToAssembly(RCInfo, AN) 'Build everything End Sub End Module ----------------------------------------------------------------------------- Copyright 1997-2024 Jeffrey Friedl