using System; using System.Text.RegularExpressions; public class Test { public static void Main() { string fullText = @"Borrower: Guarantor: {{0_SH}} By: {{1_SH}} (seal) By: (seal) Print Name: Print Name: Phillip Moore Phillip Moore Date: {{1_DH}} 2/23/2022 Title: Owner Date: {{0_DH}} 2/23/2022 12 of 12 (LOC 2020) Borrower Initials {{0_IH}} Borrower: Guarantor: {{0_SH}} By: {{1_SH}} (seal) By: (seal) Print Name: Print Name: Phillip test Moore Phillip test Moore Date: {{1_DH}} 2/23/2022 Title: Owner Date: {{0_DH}} 2/23/2022 12 of 12 (LOC 2020) Borrower Initials {{0_IH}}"; string pattern = @"\bPrint\sName:\r?\n(?!Print\sName)(?'guarantor1'[a-zA-Z\s',.&\d\--]+?)(?= \1\r?$)"; Regex rgx = new Regex(pattern, RegexOptions.Multiline); MatchCollection matches = rgx.Matches(fullText); if (matches.Count > 0) { string guarantor1 = matches[0].Groups["guarantor1"].Value; Console.WriteLine(guarantor1.Trim()); } } }