fork download
  1. using System;
  2. using System.Text.RegularExpressions;
  3.  
  4. public class Test
  5. {
  6. public static void Main()
  7. {
  8. string pattern = @"(?s)(?<=^FROM HERE\b.*?)\r?\n\r?\n(?=.*?^TO HERE\b)";
  9. string substitution = "\n$$$$\n";
  10. string input = @"3 bla bla! !
  11.  
  12. 4 yep yep! ?
  13.  
  14. FROM HERE
  15.  
  16. 5 something randdom here!
  17.  
  18. 6 perhaps some HTML there
  19.  
  20. TO HERE
  21.  
  22. 7 what ever you like over here
  23.  
  24. 8 and that's all folks!enter code here";
  25. RegexOptions options = RegexOptions.Multiline;
  26.  
  27. Regex regex = new Regex(pattern, options);
  28. string result = regex.Replace(input, substitution);
  29. Console.WriteLine(result);
  30. }
  31. }
Success #stdin #stdout 0.08s 21116KB
stdin
Standard input is empty
stdout
3 bla bla! !

4 yep yep! ?

FROM HERE
$$
5 something randdom here!
$$
6 perhaps some HTML there
$$
TO HERE

7 what ever you like over here

8 and that's all folks!enter code here