using System; using System.Collections; using System.Text.RegularExpressions; public class MyClass { public static void Main() { string stringToMatch = @"

new text more text for version 2 An internal link to Page Name. An internal link to A Page that doesn't exist. An external link to localhost.




some lines later, should be in a new paragraph.

"; string pattern = @"(?<=)(?.[\w\W]*?)?(?=

)"; Regex r = new Regex(pattern, RegexOptions.IgnoreCase | RegexOptions.Multiline | RegexOptions.IgnorePatternWhitespace); int i = 0; foreach(Match m in r.Matches(stringToMatch)){ Console.WriteLine(string.Format("------------BEGIN MATCH {0}------------", i)); Console.WriteLine(m.Value); Console.WriteLine(string.Format("-------------END MATCH {0}-------------", i)); i++; } RL(); } #region Helper methods private static void WL(object text, params object[] args) { Console.WriteLine(text.ToString(), args); } private static void RL() { Console.ReadLine(); } private static void Break() { System.Diagnostics.Debugger.Break(); } #endregion } Microsoft (R) Visual C# .NET Compiler version 7.10.6001.4 for Microsoft (R) .NET Framework version 1.1.4322 Copyright (C) Microsoft Corporation 2001-2002. All rights reserved. ------------BEGIN MATCH 0------------ new text more text for version 2 An internal link to Page Name. An internal link to A Page that doesn't exist. An external link to localhost. -------------END MATCH 0------------- ------------BEGIN MATCH 1------------ some lines later, should be in a new paragraph. -------------END MATCH 1------------- Microsoft (R) Visual C# 2005 Compiler version 8.00.50727.42 for Microsoft (R) Windows (R) 2005 Framework version 2.0.50727 Copyright (C) Microsoft Corporation 2001-2005. All rights reserved. ------------BEGIN MATCH 0------------ new text more text for version 2 An internal link to Page Name. An internal link to A Page that doesn't exist. An external link to localhost. -------------END MATCH 0------------- ------------BEGIN MATCH 1------------ some lines later, should be in a new paragraph. -------------END MATCH 1-------------