fork 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 markdown = "[url=https://stackoverflow.com/a b]SO[/url]";
  12. var p = @"(?i)\[url=([^]]+)](.*?)\[/url]";
  13. var result = Regex.Replace(markdown, p, x =>
  14. $"[{x.Groups[2].Value}]({x.Groups[1].Value.Replace(" ","%20")})");
  15. Console.WriteLine(result);
  16. }
  17. }
Success #stdin #stdout 0.1s 21208KB
stdin
Standard input is empty
stdout
[SO](https://stackoverflow.com/a%20b)