using System; using System.Collections.Generic; using System.IO; using System.Linq; using System.Text.RegularExpressions; public class Test { public static void Main() { var s = ">>1<< First Option For Third Variable Reply1 >>1<<\n\n>>2<< Second Option For Third Variable Reply 1 >>2<<\n\n>>3<< Third Option For Third Variable Reply 1 \n>>3<<"; var rx = @"(?<=>>([0-9]+)<<).*?(?=>>\1<<)"; var results = Regex.Matches(s, rx, RegexOptions.Singleline) .Cast() .Select(m => m.Value); Console.WriteLine(string.Join("\n", results)); } }