fork download
  1. using System;
  2. using System.Text.RegularExpressions;
  3.  
  4. public class Test
  5. {
  6. public static void Main()
  7. {
  8. string str = "11&222&&333&&&44444&&&&55&&&&&";
  9. str = Regex.Replace(str, "&((?:(?<2>&)(?<-2>&)?)*)", "$1$2");
  10. Console.WriteLine(str);
  11. }
  12. }
Success #stdin #stdout 0.11s 24704KB
stdin
Standard input is empty
stdout
11222&&333&&44444&&&&55&&&&