fork download
  1. using System;
  2. using System.Text.RegularExpressions;
  3. using System.Collections.Specialized;
  4. class Program
  5. {
  6. static void Main() {
  7. var myRegex = new Regex(@"{[^}]*}|(#+)");
  8. string s1 = @"# {0}mm ####{1:0.##}mm ##x {2:0.##}mm";
  9.  
  10. string replaced = myRegex.Replace(s1, delegate(Match m) {
  11. if (m.Groups[1].Value != "") return "";
  12. else return m.Value;
  13. });
  14. Console.WriteLine("\n" + "*** Replacements ***");
  15. Console.WriteLine(replaced);
  16.  
  17.  
  18. Console.WriteLine("\nPress Any Key to Exit.");
  19. Console.ReadKey();
  20.  
  21. } // END Main
  22. } // END Program
Success #stdin #stdout 0.07s 34760KB
stdin
Standard input is empty
stdout
*** Replacements ***
 {0}mm {1:0.##}mm x {2:0.##}mm

Press Any Key to Exit.