fork download
  1. using System;
  2. using System.Linq;
  3. using System.Text.RegularExpressions;
  4.  
  5. public class Test
  6. {
  7. public static void Main()
  8. {
  9. var s = "This- -is - a test-sentence. -Test- --- One-Two--Three---Four----.";
  10. var result = Regex.Replace(s, @"\b(-+)\b|-", "$1");
  11. Console.WriteLine(result);
  12. }
  13. }
Success #stdin #stdout 0.08s 19920KB
stdin
Standard input is empty
stdout
This is  a test-sentence. Test  One-Two--Three---Four.