fork download
  1. using System;
  2. using System.Text.RegularExpressions;
  3.  
  4. public class Test
  5. {
  6. public static void Main()
  7. {
  8. string text = @"My arbitrary content....
  9.  
  10. ```c#
  11. public class Foo
  12. {
  13. //Some code
  14. }
  15. ```
  16.  
  17. Some text
  18.  
  19. ```c#
  20. public class Bar
  21. {
  22. //Some code
  23. }
  24. ```
  25.  
  26. My other arbitrary content....";
  27.  
  28. text = Regex.Replace(
  29. text,
  30. @"^```c#\r?\n(.*?)```\r?\n", "$1",
  31. RegexOptions.Singleline | RegexOptions.Multiline);
  32.  
  33. Console.WriteLine(text);
  34. }
  35. }
Success #stdin #stdout 0.04s 38312KB
stdin
Standard input is empty
stdout
My arbitrary content....

public class Foo
{
    //Some code
}

Some text

public class Bar
{
    //Some code
}

My other arbitrary content....