fork(2) download
  1. using System;
  2. using System.Collections.Generic;
  3. using System.IO;
  4. using System.Linq;
  5. using System.Text.RegularExpressions;
  6.  
  7. public class Test
  8. {
  9. public static void Main()
  10. {
  11. var input = "text, *text*, text, text, (text), [text], [some_text with _*](http://.....) *text*, text, text, (text), [text]";
  12. var pattern = @"(\[[^][]*]\([^()]*\))|[][()*_]";
  13. Console.WriteLine(Regex.Replace(input, pattern, m =>
  14. m.Groups[1].Success ? m.Groups[1].Value : $@"\{m.Value}"));
  15. }
  16. }
Success #stdin #stdout 0.13s 29512KB
stdin
Standard input is empty
stdout
text, \*text\*, text, text, \(text\), \[text\], [some_text with _*](http://.....) \*text\*, text, text, \(text\), \[text\]