fork download
  1. using System;
  2. using System.Linq;
  3. using System.Collections.Generic;
  4. using System.Text.RegularExpressions;
  5.  
  6. public class Test
  7. {
  8. public static void Main()
  9. {
  10. var text = "[(Hello) <world>;.,]++--\t\"'";
  11. var result = Regex.Replace(text, @"([][()<>])|(\+\+|--)|[""'\t;.,]", m =>
  12. m.Groups[1].Success ? $" {m.Groups[1].Value} " :
  13. m.Groups[2].Success ? $" {m.Groups[2].Value}" : "")
  14. .Replace("[", "(").Replace("]", ")");
  15. Console.WriteLine(result);
  16. }
  17. }
Success #stdin #stdout 0.08s 19672KB
stdin
Standard input is empty
stdout
 (  ( Hello )   < world >  )  ++ --